useful SQL queries
Find all users that are in tblUser table but are not in tblTransaction (very useful if there’s a foreign key issue)
SELECT USER_ID FROM tblTransaction WHERE USER_ID NOT IN (SELECT ID FROM TBLUSER)
Now this one is used when you have a table linking a many to many relationship. This query pulls all currently assigned individuals and the event countries they are assigned to:
SELECT FIRST_NAME, COUNTRY
FROM tblEventContact t1, tblContact t2, tblEvent t3
WHERE t2.id = t1.contact_id
AND t3.id = t1.event_id
FROM tblEventContact t1, tblContact t2, tblEvent t3
WHERE t2.id = t1.contact_id
AND t3.id = t1.event_id
SELECT FIRST_NAME, COUNTRYFROM tblEventContact t1, tblContact t2, tblEvent t3where t2.id = t1.contact_idand t3.id = t1.event_id