I have this query built from a web form. The form will add to the query
depending on what search criteria has been chosen. what happens is if they
choose the criteria in the query below, it stops comparing the other
criteria such as listed date and price range. Also the = operator does not
return any results, and the <=> operator returns a syntax error at the >. I
am hopelessly confused.

SELECT
listings.lid,listings.Price,Area.Area,listings.Description,listings.Sold,lis
tings.MLS_Number FROM listings LEFT JOIN Companies ON
(listings.cid=Companies.cid) LEFT JOIN Area ON (listings.Area=Area.aid) LEFT
JOIN rid ON (listings.rid=rid.rid) LEFT JOIN Property_Type ON
(listings.Property_Type=Property_Type.ptid) LEFT JOIN Property_Style ON
(listings.Property_Style=Property_Style.psid) WHERE listings.Area = '19' or
listings.Area='25' or listings.Area='24' or listings.Area='32' or
listings.Area='33' or listings.Area='28' or listings.Area='38' or
listings.Area='39' or listings.Area='34' or listings.Area='20' or
listings.Area='18' or listings.Area='22' or listings.Area='27' or
listings.Area='17' or listings.Area='23' or listings.Area='29' or
listings.Area='31' or listings.Area='37' or listings.Area='35' or
listings.Area='36' AND TO_DAYS(NOW()) - TO_DAYS(Listed) < 7 AND Price>75000

It seems as soon as it hits the first OR condition, it ignores the AND
condition. I was hoping the brackets would help, but it doesn't seem to
matter. It works fine as long as I stick to AND. The numbers are the id for
area types in another table that link to the listings table. How else can I
check for a number of different area types and still further narrow the
search down with other criteria?

JD Daniels


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to