Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another LEFT JOIN trouble ... 1

Status
Not open for further replies.

Swafnil

Programmer
Jun 5, 2002
2
DE
Hi dudes,

i got some problems creating an SQL statement similar to the one mentioned in post "Query to get all Data in One Table, Matching of Another" but my one's slight more complex I guess:

Imagine I had table "items"("itemid","name") and table "prices" ("customerid","itemid") and I had to select all the items and also prices, if available, but only for one specific customer.
My current SQL looks like this:
"SELECT itemid,name,price FROM items LEFT JOIN prices ON items.itemid = prices.itemid WHERE prices.customerid = '12345'"
-> this returns only items with prices!:-(

How would I display all items with customer specific prices or (if not found) NULL?

Thanks for help!!

Sascha
 
SELECT itemid,name,price FROM items LEFT JOIN prices ON items.itemid = prices.itemid and prices.customerid = '12345'
 
Thanks for your help swampBoogie! That did the job!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top