有三个表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 直接来说数据过滤一下 
                    
                    
                1 回答
 
                    
                    
                            慕尼黑8549860
                            
                                
                            
                        
                        
                                                
                    TA贡献1818条经验 获得超11个赞
- 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 
添加回答
举报
0/150
	提交
		取消
	