Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> select * from table_a ;
- +------+--------+-----------------+
- | id | mailid | address |
- +------+--------+-----------------+
- | 11 | 1 | tung@email.com |
- | 12 | 2 | jason@email.com |
- | 13 | 3 | NULL |
- | 14 | 4 | aa@email.com |
- | 15 | 5 | bb@email.com |
- | 16 | 6 | cc@email.com |
- +------+--------+-----------------+
- 6 rows in set (0.00 sec)
- mysql> select * from table_b ;
- +------+--------+------+
- | id | mailid | code |
- +------+--------+------+
- | 1 | 1 | aa |
- | 2 | 2 | bb |
- | 3 | 3 | ccc |
- +------+--------+------+
- 3 rows in set (0.00 sec)
- mysql> select table_a.id, table_a.mailid, address, code from table_a
- -> left outer join table_b on table_b.mailid = table_a.mailid
- -> ;
- +------+--------+-----------------+------+
- | id | mailid | address | code |
- +------+--------+-----------------+------+
- | 11 | 1 | tung@email.com | aa |
- | 12 | 2 | jason@email.com | bb |
- | 13 | 3 | NULL | ccc |
- | 14 | 4 | aa@email.com | NULL |
- | 15 | 5 | bb@email.com | NULL |
- | 16 | 6 | cc@email.com | NULL |
- +------+--------+-----------------+------+
- 6 rows in set (0.01 sec)
- mysql>
Add Comment
Please, Sign In to add comment