JOIN is broadly divided into three categories as follows:
INNER Join(inner join, or equivalent connection): Gets a record of two tables that have a connection matching relationship.
Left join: Gets the left table (table1) full record, that is, the right table (table2) has no corresponding matching record.
Right join: In contrast to the left join, get the full record of the right table (table2), which is the Table1 with no matching records.
Note:MySQL does not support full join, but you can use the Union keyword to merge the LEFT join with the right join to simulate full join.
I. Inner JOIN
Inner joins, also known as equivalent connections, inner join produces a set of data that meets both A and B.
SELECT * FROM table1 inner joins table2 on table1.name = Table2.name;
Second, left Join
Left join, (or left outer join: equivalent in MySQL, we recommend using the left join. A left connection from the left table (A) produces a complete set of records, with matching records (right table (B)). If there is no match, the right side will contain null.
SELECT * FROM table1 left JOIN table2 on table1.name = Table2.name;
Third, right Join
SELECT * FROM table1 right JOIN table2 on table1.name = Table2.name;
Update:
UPDATE table1 left JOIN table2 on table1.id=table2.a_id SET table1.title= ' aaaaa ', table2.body= ' bbbb ' WHERE table1.id=1www
Delete:
DELETE table1,table2 from table1 INNER JOIN table2 on table1.uid=table2.uid WHERE table1.uid= ' 168953 '
How to use MySQL join