我的主要问题是我不知道如何说在这个条件上选择1,在那个条件上选择2。所以我给他们两个都写了自己的声明。有没有办法把它们结合起来呢?
select 1 from FlagContent where user=? and rev = ?;
select 2 from ContentRevision r
join ContentRevision r2 on r.content=r2.content
join FlagContent fc on fc.user=? and fc.rev = r2.id
where r.id=?;发布于 2011-01-21 22:48:14
使用UNION“合并”相似的结果集。
SQL UNION允许您将来自多个表的两个或两个以上结果集组合在一起。
但是,使用它有一些条件:
select 1 from FlagContent where user=? and rev = ?;
UNION ALL
select 2 from ContentRevision r
join ContentRevision r2 on r.content=r2.content
join FlagContent fc on fc.user=? and fc.rev = r2.id
where r.id=?;https://stackoverflow.com/questions/4760123
复制相似问题