A) Internal connection (equivalent connection): Query customer Name, order number, order price
---------------------------------------------------
Select C.name,o.isbn,o.price
From customers c INNER JOIN orders O
where c.id = o.customers_id;
---------------------------------------------------
Select C.name,o.isbn,o.price
From customers c join orders O
where c.id = o.customers_id;
---------------------------------------------------
Select C.name,o.isbn,o.price
From Customers c,orders O
where c.id = o.customers_id;
---------------------------------------------------
Select C.name,o.isbn,o.price
From customers c join orders O
on c.id = o.customers_id;
---------------------------------------------------
Note: The internal connection (equivalent connection) can only query out multiple tables, join the same field records
Second) outside connection: According to the customer group, query each customer's name and order number
---------------------------------------------------
Left Outer connection:
Select C.name,count (O.ISBN)
From customers C left outer JOIN orders O
On c.id = o.customers_id
Group BY C.name;
---------------------------------------------------
Right outer connection:
Select C.name,count (O.ISBN)
From Orders O right outer join customers C
On c.id = o.customers_id
Group BY C.name;
---------------------------------------------------
Note: Outer joins can query more than one table, join fields of the same record, and according to a party, the other party does not conform to the same record forcibly queried
III) Self-connection: Find out the boss of AA is EE
---------------------------------------------------
Internal Self-Connection:
Select Users.ename,boss.ename
From Emps users INNER join Emps boss
on users.mgr = Boss.empno;
---------------------------------------------------
External self-Connection:
Select Users.ename,boss.ename
From Emps users left OUTER join Emps boss
on users.mgr = Boss.empno;
---------------------------------------------------
Note: A self-join is a table that, by way of an alias, is treated as multiple tables and then connected.
At this point the connection can be connected, but also can be used outside the connection
MySQL internal connection, external connection, self-connection