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'

解决方案 »

  1.   

    select job_desc 
    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)
      

  2.   

    --result job_desc                                           
    -------------------------------------------------- 
    Publisher(1 row(s) affected)
    --不知道結果對不對
      

  3.   

    select a.job_desc 
    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% ')
      

  4.   

    select job_desc 
    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;
      

  5.   


    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
      

  6.   

    select top 1 jobs.job_desc
    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嘿嘿!
      

  7.   

    select top 1 jobs.job_desc
    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恩.应该要的是这种结果的..
    忘记了最小值这个东西其实可以排序一下然后取第一个就可以了.呵呵.
      

  8.   

    to:playwarcraft(时间就像乳沟,挤挤还是有的)汗..结完了才看到你回的..你看看.这事弄的多不好意思..^-^
      

  9.   

    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% '))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