select t.*
from talk t
where t.user_id = 2
Union
select t.*
from talk t, user_contact c
where c.user_id = 2 and c.contact_type = 1 and c.be_user_id = t.user_id
不想使用 Union 也不想去重,有没有最简单的写法?
hibernate不支持Union
可不可以使用内连接和左连接 实现呢?
select t.*
from talk t
where t.user_id = 2
Union
select t.*
from talk t, user_contact c
where c.user_id = 2 and c.contact_type = 1 and c.be_user_id = t.user_id
不想使用 Union 也不想去重,有没有最简单的写法?
hibernate不支持Union
可不可以使用内连接和左连接 实现呢?
试一试?
select t.* from t left join user_contact c
on t.user_id=c.be_user_id and c.user_id=2 and c.contact_type=1
where t.user_id=2 or c.user_id=2
8 回答6.5k 阅读
4 回答685 阅读✓ 已解决
2 回答3.4k 阅读
1 回答2.5k 阅读✓ 已解决
5 回答1.5k 阅读
3 回答1.9k 阅读✓ 已解决
1 回答2.1k 阅读✓ 已解决
1.union
2.使用异步发送两个sql过去再合并,效果和union一样