code_junkie

How do you JOIN two MySQL tables where the data is NOT in the other table?

Nov 13th, 2011
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. SELECT PETS.NAME
  2. FROM PETS
  3. LEFT OUTER JOIN LOST_PETS
  4. ON PETS.PET_ID = LOST_PETS.PET_ID
  5. WHERE LOST_PETS.PET_ID IS NULL;
  6.  
  7. SELECT *
  8. FROM pets LEFT OUTER JOIN pets-lost ON pets.id = pets-lost.id
  9. WHERE pets-lost.id IS NULL;
Add Comment
Please, Sign In to add comment