Did you want 
WHERE  Name LIKE 'sandy' 
       OR (main_data.Display_In_Search = 1 
           AND main_data.Expiry_Date >= CurDate())


OR 


WHERE  main_data.Expiry_Date >= CurDate()
       AND (Name LIKE 'sandy' 
            OR main_data.Display_In_Search = 1 )
       

-----Original Message-----
From: Richard Duke [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 17, 2005 4:03 PM
To: mysql@lists.mysql.com
Subject: Query problem

Hi

I have a problem with a query that has many joined tables. The query brings 
back 80 records instead of just one. Any suggestions on how I can overcome 
this?

Many thanks

Richard

Query below:-

SELECT *
FROM (((((((((((((main_data INNER JOIN main_data_facilities ON
main_data_facilities.RecNo = main_data.RecNo) INNER JOIN main_data_meals ON
main_data_meals.RecNo = main_data.RecNo) INNER JOIN main_data_non_smoking ON
main_data_non_smoking.RecNo = main_data.RecNo) INNER JOIN 
main_data_payment_types ON
main_data_payment_types.RecNo = main_data.RecNo) INNER JOIN 
main_data_pets_welcome ON
main_data_pets_welcome.RecNo = main_data.RecNo) INNER JOIN 
main_data_special_dietary_requirements ON
main_data_special_dietary_requirements.RecNo = main_data.RecNo) INNER JOIN 
counties ON
counties.ID = main_data.County) INNER JOIN countries ON
countries.ID = main_data.Country) INNER JOIN facilities ON
facilities.ID = main_data_facilities.ID) INNER JOIN meals ON
meals.ID = main_data_meals.ID) INNER JOIN non_smoking ON
non_smoking.ID = main_data_non_smoking.ID) INNER JOIN payment_types ON
payment_types.ID = main_data_payment_types.ID) INNER JOIN pets_welcome ON
pets_welcome.ID = main_data_pets_welcome.ID) INNER JOIN 
special_dietary_requirements ON
special_dietary_requirements.ID = main_data_special_dietary_requirements.ID 
AND main_data_meals.RecNo = main_data_facilities.RecNo
WHERE Name LIKE 'sandy'
OR ( main_data.Display_In_Search = 1 )
AND ( main_data.Expiry_Date >= CurDate() )


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to