为了进行测试,我们先假想一个常用的电子商务网站上可能用到的数据结构模型。在关系数据库MySQL中我们可能需要设计3个表如客户表customers、订单表orders、商品表products,其中 customers表中的主键为cust_id,products表中的主键为prod_id,orders表中主键order_id,外键cust_id和prod_id分别与客户和产品关联,这就是在关系数据库中经常干的事情,整个结构如图所示。

查询某个客户所订购的所有商品名称的SQL语句则为以下格式。
select t1.name,t3.prod_name from customer t1
join orders t2