Bạn có thể sử dụng UNION
(xóa các bản sao trước) hoặc UNION ALL
:
SELECT CASE WHEN EXISTS
( SELECT 1 FROM ( SELECT m_id FROM A
UNION
SELECT m_id FROM B
UNION
SELECT m_id FROM C
UNION
SELECT m_id FROM D
UNION
SELECT m_id FROM E ) All
WHERE All.m_id = 'some_id')
THEN 1 ELSE 0 END AS ContainsID