select job_desc
from jobs
where job_id in (
select min(job_id) from employee where pub_id=(
select pub_id from titles where type like 'undec% '))把这段查询用联结的方法写出来.
就是用那个join on的写发写出来.select jobs.job_desc
from jobs
join employee
on jobs.job_id in (min(employee.job_id))
join titles
on employee.pub_id = titles.pub_id
where titles.type like 'undec% '但是聚合函数不能用在ON语句里呀..
这可杂改?老师留的题目..郁闷..例:
--原题
select *
from titles
where pub_id = (select pub_id from publishers where city='Boston')--使用自然连接
select *
from titles join publishers
on titles.pub_id=publishers.pub_id
where publishers.city='boston'
from jobs
where job_id in (
select min(job_id) from employee where pub_id=(
select pub_id from titles where type like 'undec% '))把这段查询用联结的方法写出来.
就是用那个join on的写发写出来.select jobs.job_desc
from jobs
join employee
on jobs.job_id in (min(employee.job_id))
join titles
on employee.pub_id = titles.pub_id
where titles.type like 'undec% '但是聚合函数不能用在ON语句里呀..
这可杂改?老师留的题目..郁闷..例:
--原题
select *
from titles
where pub_id = (select pub_id from publishers where city='Boston')--使用自然连接
select *
from titles join publishers
on titles.pub_id=publishers.pub_id
where publishers.city='boston'
解决方案 »
- 求一条SQL语句
- 关于SQL注入
- 求一个sql的问题急求!!
- 这样的功能存储过程如何实现?
- 如何检索一段时间内的记录?请指点
- 通過按鈕Ctrl+Alt+Delete, 看到數據庫服務器的sqlserver.exe 進程使用的內存達700多M, 并且經常變化, 請問sqlserver.exe使用內存的大小與
- 一个SQL数据表查询的问题,请帮忙
- 急救:我用 EXEC master..xp_cmdshell '路径\*.exe' 执行后,无法终止被执行的程序。怎么办?
- sql server不能启动,为什么?help!
- 如何让SQL SERVER2000定时自动运行一些存储过程并导出数据到access文件
- 数据类型转换
- 9002 错误 demo:full msdb log, demo:full msdb tempdb
from jobs
where job_id=(
select top 1 job_id from employee
inner join titles on employee.pub_id=titles.pub_id
where titles.type like 'undec% '
order by job_id asc)
--------------------------------------------------
Publisher(1 row(s) affected)
--不知道結果對不對
from jobs a , employee b , titles c
where a.job_id in (min(b.job_id)) and b.pub_id = c.pub_id and c.type like 'undec% '
或者select job_desc
from jobs
where job_id in
(select min(job_id) from employee b , titles c
where b.pub_id=c.pub_id and c.type like 'undec% ')
from jobs aa
join (
select min(job_id) job_id from employee b join (
select pub_id from titles where type like 'undec% ') c
on pub_id=c.pub_id) bb
on aa.job_id=bb.job_id;
select job_desc
from jobs t3 inner join
(
select min(job_id)
from employee inner join titles on t1.pub_id= t2.pub_id
where t2.type like 'undec% '
) t4 on t3.job_id = t4.job_id
from jobs
join employee
on jobs.job_id in (employee.job_id)
join titles
on employee.pub_id = titles.pub_id
where titles.type like 'undec% '
order by employee.job_id嘿嘿!
from jobs
join employee
on jobs.job_id in (employee.job_id)
join titles
on employee.pub_id = titles.pub_id
where titles.type like 'undec% '
order by employee.job_id恩.应该要的是这种结果的..
忘记了最小值这个东西其实可以排序一下然后取第一个就可以了.呵呵.
from jobs
where job_id in (
select min(job_id) from employee where pub_id=(
select pub_id from titles where type like 'undec% '))select top 1 job_desc
from jobs
join employee on jobs.job_id=employee.job_id
join titles on employee.pub_id=titles.pub_id and titles.type like 'undec%'
order by jobs.job_id