ms access - SQL Show fields that match WHERE statement otherwise show the others -
these parameters working , can entries show match item 'dress shirt' don't know how show others if don't match 'dress shirt'. have been trying use and/or can't show right.
"show lastname, firstname, phone , total amount of customers have had order item named "dress shirt". show lastname, firstname , phone of other customers. present results sorted lastname in ascending order , firstname in descending order."
select lastname, firstname, phone, totalamount customer, invoice, invoice_item customer.customerid = invoice.customernumber , invoice.invoicenumber = invoice_item.invoicenumber , item ='dress shirt';
try this:
select lastname, firstname, phone, totalamount customer inner join invoice on customer.customerid = invoice.customernumber left join invoice_item on invoice.invoicenumber = invoice_item.invoicenumber , invoice_item.item ='dress shirt' ;
access might insist on parenthese joins, this:
select lastname, firstname, phone, totalamount ((customer inner join invoice on customer.customerid = invoice.customernumber) left join invoice_item on invoice.invoicenumber = invoice_item.invoicenumber , invoice_item.item ='dress shirt') ;
if aren't familiar left joins this example may help.
Comments
Post a Comment