select a.*,b.* from a,b where a.item = b.item

解决方案 »

  1.   

    select a.*,b.*  from  a left join b on(a.item=b.item)
      

  2.   

    楼上的好象全不对啊,我测试了,那样写,也会把A表里没有和B表ITEM字段值相等的记录漏掉,
    我的前提是要保留A表里所有记录,再和B表做连接查询
      

  3.   

    A                                  B
    ITEM  ITEM_DESC                   ITEM     STK
    555    123                        557       15
    556    224                        558       16
    557    336
    558    156
    我想要得到的结果是
    ITEM   ITEM_DESC         STK
    555     123              NULL
    556     224              NULL
    557     336              15
    558     156              16
    如果按楼上所写,只有最后两条记录了
      

  4.   

    select a.*,b.*  from  a left join b on(a.item=b.item)
    这个肯定是正确地!我刚测试了
    本来left join就是取左表的记录(包括右表中没有的)
    right join正好相反!
      

  5.   

    select a.item, a.item_desc, b.stk
    from a left join b on a.item = b.item
      

  6.   

    --测试数据
    create table a (item int,item_Desc nvarchar(1000))insert into a 
    select 555,'123'
    union all
    select 556,'224'
    union all
    select 557,'336'
    union all
    select 558,'156'create table b (item int, stk int)insert into b
    select 557,15
    union
    select 558,16select a.*,b.stk from a left join b on a.item = b.item
      

  7.   

    --结果
    555 123 NULL
    556 224 NULL
    557 336 15
    558 156 16