Code: Select all
SELECT u.user_id, un.item_type, un.method, un.notify
FROM test u
LEFT JOIN test2 un ON (un.user_id = u.user_id OR un.user_id IS NULL)
AND (un.item_type = 1 OR un.item_type IS NULL)
AND (un.notify = 1 OR un.notify IS NULL)
Code: Select all
SELECT u.user_id, un.item_type, un.method, un.notify
FROM test u
LEFT JOIN test2 un ON (un.user_id = u.user_id OR un.user_id IS NULL)
AND (un.item_type = 1 OR un.item_type IS NULL)
WHERE (un.notify = 1 OR un.notify IS NULL)