select c_tid,c_cid,C_ArchivesID,C_Company
from t_sales,t_communication where c_tid = 2 and c_cid = C_Company
c_tid,c_cid是表t_sales的2个字段,C_ArchivesID,C_Company是表t_communication的2个字段
我的目的是想查询c_tid = 2时的C_Company的值,按照我这样写,没有返回值,可是应该有返回值的。
是不是SQL语句错了?请问该怎么改呢?我这样的查询算法是不是不高效?应该怎么样是合理的呢?
谢谢

解决方案 »

  1.   

    ..select ts.c_tid,ts.c_cid,tc.C_ArchivesID,tc.C_Company
    from t_sales ts,t_communication tc where ts.c_tid = 2 and ts.c_cid = tc.C_Company 
      

  2.   

    2个表的联接字段是什么呢?猜下:select t1.c_tid,t1.c_cid,t2.C_ArchivesID,t2.C_Company 
      from t_sales t1,t_communication t2 
        where t1.c_tid = 2 and t1.c_cid = t2.C_ArchivesID  ???还是:select t1.c_tid,t1.c_cid,t2.C_ArchivesID,t2.C_Company 
      from t_sales t1,t_communication t2 
        where t1.c_tid = 2 and t1.c_cid = t2.C_Company  ???
      

  3.   

    t1.c_cid = t2.C_ArchivesID是关联的
    但是依旧没有返回值。
      

  4.   

    贴下你的表结构以便分析:show create table t_sales;
    show create table t_communication;