Two queries query the same table and return the same result set. Is there any way to merge the result set except 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

I don"t want to use Union and I don"t want to weigh it. Is there the easiest way to write it?

hibernate does not support Union

Can

be implemented using inner and left connections?

Jun.27,2021

1.union
2. Send two sql asynchronously and then merge them. The effect is the same as union


give it a try?

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
Menu