猿问

我现在想要获得a表的数据,且这些数据对应表的数据del不能为true ?该怎么做?

有三个表a,b,c 
a表的架构是 
id   atype   rid 
1     b       1 
2     c       1 
3     c       2 
4     b       2 
5     b       3 
6     c       3 


atype中的b,表示这条代表是b表的, c表示c表的 

b表的结构是 

id   del 
1    true 
2    false 
3    false 

c表 

id   del 
1    true 
2    false 
3    false 


如查询结果 

id   atype   rid 
3     c       2 
4     b       2 
5     b       3 
6     c       3 

直接来说数据过滤一下 

LEATH
浏览 122回答 1
1回答

慕尼黑8549860

SELECT * from   (SELECT a.id,a.atype,a.rid from a,b where a.rid = b.id and a.atype = 'b' and b.del = 'false'  union  SELECT a.id,a.atype,a.rid from a,c where a.rid = c.id and a.atype = 'c' and c.del = 'false') tbl  order by tbl.id asc  
随时随地看视频慕课网APP

相关分类

MySQL
我要回答