Hi,
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:
This doesn't work either when I use the DISTINCT keyword:
I don't care if the Products.Produc tName or Transactions.Qu antity etc. are equal just as long as the Customers.Custo merFirstName and Customers.Custo merLastName are not equal to other customers, so that I won't get multiple entries for the same customer, how do I go about doing this?
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:
Code:
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
Code:
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
Comment