此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【fjxmt】截止到2008-07-07 03:10:51的历史汇总数据(不包括此帖):
发帖的总数量:1                        发帖的总分数:20                       
结贴的总数量:0                        结贴的总分数:0                        
无满意结贴数:0                        无满意结贴分:0                        
未结的帖子数:1                        未结的总分数:20                       
结贴的百分比:0.00  %               结分的百分比:0.00  %                  
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html

解决方案 »

  1.   

    select distinct T1.uid from 
    (
    select T1.uid,t2.com com2,t3.com com3,t4.com com4 from T1 
    left join T2 on t2.uid = t1.uid
    left join T3 on t3.uid = t1.uid
    left join T4 on t4.uid = t1.uid
    } where com2='txt' OR com3='txt' OR com4='txt'我想到的就是Join方法,如果数据量大,性能会有影响。不知道 exitst 这个方法会不会性能高一些。其他人继续吧!
      

  2.   

    (select * from t1 left join c1 on t1.uid = c1.uid where c1.com = 'c1')
    union
    (select * from t1 left join c1 on t1.uid = c2.uid where c2.com = 'c1')
    union
    (select * from t1 left join c1 on t1.uid = c3.uid where c3.com = 'c1')
    select * from t1 left join c1 on t1.uid = c1.uid left join c2 on t1.uid = c2.uid  left join c3 on t1.uid = c3.uid where c1.com = 'c1' or  c2.com = 'c2' or  c3.com = 'c3'
      

  3.   

    改正一下,,复制错了。select * from t1 left join c1 on t1.uid = c1.uid where c1.com = 'c1' 
    union 
    select * from t1 left join c2 on t1.uid = c2.uid where c2.com = 'c1' 
    union  
    select * from t1 left join c3 on t1.uid = c3.uid where c3.com = 'c1' 
      

  4.   

    select t1.* from t1,t2,t3 
    where t1.uid=t2.uid AND t2.uid=t3.uid AND (t1.com='txt OR t2.com='txt' OR t3.com='txt')
      

  5.   

    这个我觉得很好.性能上不敢说什么(没测试).
    [/Quote]
    当数据量多的时候,对等快。
    当数据量少的时候。left join快
      

  6.   

    select t1.* from t1,c1,c2,c3 
    where concat(c1.uid,c2.uid,c3.uid)=ti.uid and concat(c1.com,c2.com,c3.com)='txt'
      

  7.   

     
    这个我觉得很好.性能上不敢说什么(没测试).
    [/Quote]
      

  8.   

    感谢各位的指点,特别感谢6楼inter_lxp,不知道是自己测试有问题,还是什么,没给出正确的结果,我借鉴一下,修改为
    select T1.* from T1,C1,C2,C3 
    where (T1.uid=C1.uid and C1.com='txt') or (T1.uid=C2.uid and C2.com='txt') or (T1.uid=C3.uid and C3.com='txt')
    以上例句,经初步测试,符合正确结果。其它的例句,因水平和时间有限,未进行测试,望见谅。
    谢谢各位。