Tidak dijelaskan apakah urutan set hasil itu penting, jadi sebaiknya coba:
SELECT name,
value
FROM MyTable
WHERE id = 5
AND id NOT IN
(
SELECT id
FROM MyTable
WHERE id = 0
GROUP BY MyTable.id
)
UNION
SELECT name,
value
FROM MyTable
WHERE id = 0
AND name NOT IN
(
SELECT name
FROM MyTable
WHERE id = 5
GROUP BY MyTable.name
)
Penafian:Diuji di SQL Server, tetapi tidak menggunakan sesuatu yang spesifik untuk versi SQL tersebut.