您的位置:程序门 -> ms-sql server -> 基础类



这样的sql联接语句怎么写?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


这样的sql联接语句怎么写?[已结贴,结贴人:bluesun]
发表于:2007-06-19 11:48:20 楼主
select   laowu.name,sb_feerecord.ygid,sb_feerecord.sb_month,
sb_yanlao_unit,sb_losjob_unit,gzjb_id_unit  
    from   laowu,sb_feerecord,gzjb  
    where   laowu.id=sb_feerecord.ygid  
        and   laowu.id=gzjb.ygid
        and   gzjb.id=sb_feerecord.gzjb_id_unit

select   laowu.name,sb_feerecord.ygid,sb_feerecord.sb_month,
sb_yanlao_per,sb_medcal_per,gzjb_id_personl
    from   laowu,sb_feerecord,gzjb  
    where   laowu.id=sb_feerecord.ygid  
        and   laowu.id=gzjb.ygid
        and   gzjb.id=sb_feerecord.gzjb_id_personl

查询出的这个两个表如果要用两个表的ygid关联,应该怎么写.
发表于:2007-06-19 11:53:311楼 得分:20
select   *   from  
(第一句)aa
inner   join
(第二句)bb
on   aa.ygid=bb.ygid
发表于:2007-06-19 15:53:002楼 得分:0
(第一句)   into   #a  
(第二句)   into   #b  

select   *   from
#a   aa
inner   join
#b   bb
on   aa.ygid=bb.ygid


快速检索

最新资讯
热门点击