I want to join two tables together and only select the rows that don't have the same customer first name and last name (see my code below). When I run my code with the DISTINCT keyword, it still returns me all of the rows probably because it requires each column to be the same in order to find distinct rows, but I want the rows just as long as the customer first and last names are different from other customers:
Expand|Select|Wrap|Line Numbers
- use AppDb
- SELECT Customers.CustomerFirstName, Customers.CustomerLastName, Products.ProductName, Transactions.Quantity, Transactions.OrderTotal, Transactions.PaymentMethod, Transactions.OrderDate
- FROM Customers
- JOIN Transactions
- ON Customers.CustomerNo = Transactions.CustomerNo
- JOIN Products
- ON Products.ProductID = Transactions.ProductID
Expand|Select|Wrap|Line Numbers
- use AppDb
- SELECT DISTINCT Customers.CustomerFirstName, Customers.CustomerLastName, Products.ProductName, Transactions.Quantity, Transactions.OrderTotal, Transactions.PaymentMethod, Transactions.OrderDate
- FROM Customers
- JOIN Transactions
- ON Customers.CustomerNo = Transactions.CustomerNo
- JOIN Products
- ON Products.ProductID = Transactions.ProductID