Guest User

Untitled

a guest
Mar 12th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1.  
  2. mysql> select * from table_a ;
  3. +------+--------+-----------------+
  4. | id | mailid | address |
  5. +------+--------+-----------------+
  6. | 11 | 1 | tung@email.com |
  7. | 12 | 2 | jason@email.com |
  8. | 13 | 3 | NULL |
  9. | 14 | 4 | aa@email.com |
  10. | 15 | 5 | bb@email.com |
  11. | 16 | 6 | cc@email.com |
  12. +------+--------+-----------------+
  13. 6 rows in set (0.00 sec)
  14.  
  15. mysql> select * from table_b ;
  16. +------+--------+------+
  17. | id | mailid | code |
  18. +------+--------+------+
  19. | 1 | 1 | aa |
  20. | 2 | 2 | bb |
  21. | 3 | 3 | ccc |
  22. +------+--------+------+
  23. 3 rows in set (0.00 sec)
  24.  
  25. mysql> select table_a.id, table_a.mailid, address, code from table_a
  26. -> left outer join table_b on table_b.mailid = table_a.mailid
  27. -> ;
  28. +------+--------+-----------------+------+
  29. | id | mailid | address | code |
  30. +------+--------+-----------------+------+
  31. | 11 | 1 | tung@email.com | aa |
  32. | 12 | 2 | jason@email.com | bb |
  33. | 13 | 3 | NULL | ccc |
  34. | 14 | 4 | aa@email.com | NULL |
  35. | 15 | 5 | bb@email.com | NULL |
  36. | 16 | 6 | cc@email.com | NULL |
  37. +------+--------+-----------------+------+
  38. 6 rows in set (0.01 sec)
  39.  
  40. mysql>
Add Comment
Please, Sign In to add comment