【MySQL作业】连接查询——美和易思内连接查询应用习题

点击打开所使用到的数据库>>>


1、使用内连接获取客户“王传华”所有的订单信息和客户信息。

使用内连接获取客户“王传华”所有的订单信息和客户信息

select * from customer c join orders o on c.customerID=o.customerID where cName=' 王传华 '

2、使用内连接获取客户“王传华”所有的下单日期信息,要求显示客户姓名和下单日期。

使用等值连接获取客户“王传华”所有的下单日期信息

select cName 姓名 , ordersDate 下单日期 from customer c join orders o 
on c.customerID=o.customerID and cName=' 王传华 '

3、使用内连接获取客户“王传华”下单日期在 2015 年 4 月之后的订单信息,要求显示客户姓名和下单日期。

使用内连接获取客户“王传华”下单日期在 2015 年 4 月之后的订单信息

select cName 姓名 , ordersDate 下单日期 from customer c join orders o on c.customerID=o.customerID where cName=' 王传华 ' and ordersDate>'2015-04'

4、使用自然连接获取客户“王传华”所有下单日期信息,要求显示客户姓名和下单日期。

使用自然连接获取客户“王传华”所有下单日期信息

select cName 姓名 , ordersDate 下单日期 from customer natural join orders where cName=' 王传华 '

发布了112 篇原创文章 · 获赞 182 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/weixin_44893902/article/details/105655239
今日推荐