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
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9aebf-181a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9aebf-181a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?