表t1
 a    b   
01   c1
02   c2
表t2
 a    b
a1   c1
b1   c2
表t3
 e    f
c1   真的/好
c2   真的/坏
下面这条语句好像不行啊,把好、坏记录都选出来了,我只想选为"好"的记录啊
select * from (select a,b,f from t1,t3 where t1.b=t3.f union select a,b,f from t2 ,t3 where t2.b=t3.f) a,t3 where t3 like "%好%"

解决方案 »

  1.   

    select * from (select a,b,f from t1,t3 where t1.b=t3.f union select a,b,f from t2 ,t3 where t2.b=t3.f) a,t3 where t3.f like "%好%"
      

  2.   

    select * from (select a,b,f from t1,t3 where t1.b=t3.f union select a,b,f from t2 ,t3 where t2.b=t3.f) a,t3 where t3.f like '%好%'
      

  3.   

    select * from (select a,b,f from t1,t3 where t1.b=t3.f union select a,b,f from t2 ,t3 where t2.b=t3.f) a where f like "%好%"
      

  4.   

    或者:select a.a,a.b,t3.f from (select a,b from t1 union all select a,b from t2) a,t3 where a.b=t3.f and t3.f like '%好%'