现在有两张表,user和class,内容如下:
1 | MariaDB [jointest]> select * from user; |
inner join
1 | MariaDB [jointest]> select * from user inner join class on user.class_id=class.id; |
left join
1 | MariaDB [jointest]> select * from user left join class on user.class_id=class.id; |
right join
1 | MariaDB [jointest]> select * from user right join class on user.class_id=class.id; |
full join
mysql不知吃full join,不过可以通过union 合并left jion和right jion的结果来模拟full jion。
1 | MariaDB [jointest]> select * from user left join class on user.class_id=class.id |
cross join
user表一共有8条记录,class表一共有5条记录,cross join一同有8*5=40条结果。
1 | MariaDB [jointest]> select * from user cross join class; |
mysqldump
1 | -- MySQL dump 10.14 Distrib 5.5.60-MariaDB, for Linux (x86_64) |