1. Join connects data that meets the on condition to a new table.
2. where first connects the two tables to a new table through the Cartesian product, then determines the conditions and forms the data that meets the conditions into a table.
Example
1 2 3 4 | select m.menu_id,m.sort_id,s.sort_id,s.sort_name from menu m join sort s on m.sort_id=s.sort_id and m.sort_id=2;
select m.menu_id,m.sort_id,s.sort_id,s.sort_name from menu m join sort s on m.sort_id=s.sort_id where m.sort_id=2;
select m.menu_id,m.sort_id,s.sort_id,s.sort_name from menu m inner join sort s on m.sort_id=s.sort_id and m.sort_id=2;
select m.menu_id,m.sort_id,s.sort_id,s.sort_name from menu m inner join sort s on m.sort_id=s.sort_id where m.sort_id=2;
|
Copy after login
The above is the detailed content of What is the difference between join and where in mysql. For more information, please follow other related articles on the PHP Chinese website!