select vend_name, prod_name, prod_price from vendors, products order by vend_name, prod_name;
返回所有的组合,笛卡尔积。select vend_name, prod_name, prod_price from vendors inner join products on vendors.vend_id = products.vend_id
内联结(等值连接)select prod_name, vend_name, prod_price, quantity from orderitems, products, vendors where products.vend_id = vendors.vend_id and orderitems.prod_id = products.prod_id and order_num = 20005
多表连接select Contact(RTrim(vend_name), '(', RTrim(vend_country), ')') as vend_title from vendors order by vend_name
Contact生成字符串连接
1.select cust_name, cust_contact 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 = 'TNT2'
- select customers.cust_id, order.order_num from customers left outer join orders on customers.cust_id = orders.cust_id;
- select customers.cust_id, order.order_num from customers right outer join orders on customers.cust_id = orders.cust_id;