SELECT * FROM packages WHERE package_service_id LIKE '%1%' OR package_service_id LIKE '%2%' OR package_service_id LIKE '%3%' OR package_service_id LIKE '%4%' OR package_service_id LIKE '%5%' AND package_cost <= 66
the query is meant to select all packages that include the required services and that are less than or equal to the budget. so in the example query above, its looking for all packages that include any of the 5 services, and that have a cost that is less that or equal to 66.
the problem is, it returns results that are higher than 66. If i take out the last condition, it makes no difference to the results.
Both the required services and budget are dynamic.
Im sure its something to do with me using OR and AND, but im hoping someone can shed some light on the problem :D
Question
mikeaag
Hey all,
Im having a bit of trouble with an SQL query.
the query is meant to select all packages that include the required services and that are less than or equal to the budget. so in the example query above, its looking for all packages that include any of the 5 services, and that have a cost that is less that or equal to 66.
the problem is, it returns results that are higher than 66. If i take out the last condition, it makes no difference to the results.
Both the required services and budget are dynamic.
Im sure its something to do with me using OR and AND, but im hoping someone can shed some light on the problem :D
In the mean time, i'll be googling it :D
thank in advance
Link to comment
Share on other sites
8 answers to this question
Recommended Posts