可以这样查询吗:
select char1,char2,char3 from tab1,tab2 where char4='sdf'
以前课本上好象有这种写法,请教这样行吗,如果要改,在哪里改一下。

解决方案 »

  1.   

    可以啊
    只是你tab1 tab2没有关联,而且前面的几个字段如果是两个表都有就要加前缀。
      

  2.   

    如果tab1和tab2是主外键关联,那么最好写成如下形式:
    select a.char1,a.char2,b.char3 
    from tab1 a,tab2 b 
    where a.id=b.id
    and b.char4='sdf'
      

  3.   

    select a.char1,a.char2,b.char3 
    from tab1 a,tab2 b 
    where a.id=b.id
    and b.char4='sdf'
      

  4.   

    select a.char1,a.char2,b.char3 
    from tab1 a,tab2 b 
    where a.id=b.id
    and b.char4='sdf'
      

  5.   

    那这样写又如何:
       adoquery5.SQL.Add('select '''+str+''' from '''+str1+''' where '''+str2+'''');
       adoquery5.Open;
    str是表名.字段名
    str1是表名
    str2是查询条件。