有三個表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
提交
取消