Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> select * from gifts INNER JOIN sentGifts ON gifts.giftID = sentGifts.giftID;
- mysql> select * from gifts INNER JOIN sentGifts WHERE gifts.giftID = sentGifts.giftID;
- mysql> select name from gifts LEFT OUTER JOIN sentgifts
- ON gifts.giftID = sentgifts.giftID
- WHERE sentgifts.giftID IS NULL;
- gifts
- 1 Teddy bear
- 2 Flowers
- sentgifts
- 1 Alice
- 1 Bob
- ---
- SELECT *
- FROM gifts g
- LEFT JOIN
- sentgifts sg
- ON g.giftID = sg.giftID
- ---
- 1 Teddy bear 1 Alice
- 1 Teddy bear 1 Bob
- 2 Flowers NULL NULL -- no match in sentgifts
- ---
- SELECT *
- FROM gifts g
- LEFT JOIN
- sentgifts sg
- ON g.giftID = sg.giftID
- WHERE sg.giftID IS NULL
- ---
- 2 Flowers NULL NULL -- no match in sentgifts
- select *
- from Table1 t1
- inner join Table2 t2 on t1.id = t2.id
- where t1.Name = 'John'
- select *
- from Table1 t1
- inner join Table2 t2 on t1.id = t2.id
- and t1.Name = 'John'
- gifts
- 1 Teddy bear
- 2 Flowers
- sentgifts
- 1 Alice
- 1 Bob
- ---
- SELECT *
- FROM gifts g
- LEFT JOIN
- sentgifts sg
- ON g.giftID = sg.giftID
- ---
- NULL Alice
- NULL Bob
- Flowers NULL
Add Comment
Please, Sign In to add comment