课程: SQL Server Fundamentals: Master Basic Query Techniques
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Working with multiple tables
课程: SQL Server Fundamentals: Master Basic Query Techniques
Solution: Working with multiple tables
(bright music) - [Instructor] So in this solution we always want to return the customer information regardless of whether or not they have an order associated with that customer. So we're going to use a left join here when we get to the orders table. So we start with customer as C with that table alias, then we'll use a left outer join to get to orders as O. And our join condition is where the customer ID is the same in both tables. And if I were writing a regular SQL server query, I would not need this outer keyword. But because we're following ANSI standard with CoderPad, we do need to include that here. But just know in SQL server that is optional. All right, so now we've got our two tables here. We're going to start filtering, so where the customer's state equals DE. And then we know we either want to return orders where they're not marked paid or where the customer doesn't have any orders. So to accomplish that, we're going to say and, the order's status is not paid or, the order…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。