mysql must know
First there is a table
Customer table: Product table:
Order element table: Product record table:
Order Form:
Seller table:
Chapter 16 Creating Advanced Joins
select concat(rtrim(vend_name),'(',rtrim(vend_country),')') as vend_title from vendors order by vend_name;
There are two advantages to using aliases:
1. Shorten the sql statement
2. Allow multiple use of the same table in a single select statement
Use different types of joins
1. Self-association
Join yourself with your own table
select p1.prod_id,p1.prod_name from products as p1,products as p2 where p1.vend_id = p2.vend_id and p2.prod_id = 'DTNTR'
As can be seen from the above code: Use the alias of the table to associate the tables with each other
2. Natural connection
Joins between tables based on fields between tables
select c.*,o.order_num,o.order_date,oi.prod_id,oi.quantity,oi.item_price from customers as c, orders as o,orderitems as oi where c.cust_id = o.cust_id and oi.order_num = o.order_num and prod_id = 'FB'
3. External Links