select tb1.user,tb1.service,tb3.value from tb1,tb3 where tb1.service=tb3.service

解决方案 »

  1.   

    select a.user, a.service,b.value from tb1 a left join tb2 b on a.service=b.service
      

  2.   

    To pbsql(风云) :如果我要添加一个限制条件:只显示用户liming的信息,就在你的句子后面加上and tb1.user = 'liming'就可以了吗?
    我总觉得这样有些问题,怪怪的。
      

  3.   

    user是保留字,所以要加[]括起来:
    select [tb1.user],tb1.service,tb3.value from tb1,tb3 where tb1.service=tb3.service and [tb1.user] = 'liming'
      

  4.   

    括错地方了:
    select tb1.[user],tb1.service,tb3.value from tb1,tb3 where tb1.service=tb3.service and tb1.[user] = 'liming'
      

  5.   

    select tb1.user,tb2.msg,tb3.valuus from tb1,tb2,tb3 where tb1.service=tb2.service
    and tb2.service=tb3.service;
      

  6.   

    --测试
    --测试表
    create table tb1([user] char(10),service char(10))
    create table tb2(service char(10),msg char(10))
    create table tb3(service char(10),value int)
    go--测试数据
    insert tb1
    select 'liming','hh'
    union all select 'liming','hh'
    union all select 'lixiao','bb'insert tb2
    select 'hh','第一个'
    union all select 'hh','第一个'  
    union all select 'bb','第二个'
    union all select 'kk','第三个'
    insert tb3
    select 'hh',19
    union all select 'hh',19
    union all select 'bb',20  
    union all select 'kk',30
    go--显示结果
    select  distinct tb1.[user],tb2.service,tb3.value from tb1,tb2,tb3 where tb1.service=tb2.service and tb1.service=tb3.service
    go--删除测试
    drop table tb1,tb2,tb3
    我测试过,可以的
      

  7.   

    select a.user, a.service,c.value from tb1 a left join tb3 c on a.service=c.service
    where a.user='liming'
    看看这个应该可以,如果觉得不对,干脆把你要的查询的结果数据写出来好了》