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!

seach sql

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
hi - happy new year to all

am writing a search page that will return a customers details if they have records in the following tables, book OR colldelbook OR courtcarbook

at the moment all records of customers are being returned
because of the left joins

Code:
SELECT colldelbook.bookid AS cdbookid, book.bookid AS motbookid, courtcarbook.courtcarbookid AS courtcarbookid,cus.cusid, cus.fname, cus.lname, cus.add1, cus.pcode, cus.hphone, cus.wphone,cus.mphone,car.reg, book.bookdate AS motdate, colldelbook.bookdate AS cdbookdate, courtcarbook.bookst 
FROM cus 
INNER JOIN car ON car.cusid = cus.cusid
LEFT JOIN book ON book.carid = car.cusid 
LEFT JOIN colldelbook ON colldelbook.carid = car.cusid 
LEFT JOIN courtcarbook ON courtcarbook.cusid = cus.cusid "_
WHERE pcode = '" & replace(x_postcquick,"'","''") & "'"_
OR lname = '" & replace(x_lnamequick,"'","''") & "'"_
OR reg= '" & replace(x_stockregquick,"'","''") & "'"_
ORDER BY book.bookdate, colldelbook.bookdate, courtcarbook.bookst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top