Peoblem with JOIN and AND / OR
Posted: Sun Sep 19, 2010 9:09 pm
This is what I have:
It is part of a service system for generator maintenance, what I want is a list of all costumes that we are tracking service for and only the ones I care about.
So I put in "AND generators.track_service='yes'", but if there is a problem win any generator we need it to also show up on the top of the list, so I did "OR generators.flag='on'"
The problem is whenever there is a generator with the "flag" set to on the quarry shows all records in the BD?
Code: Select all
$query = "SELECT id, generator_id, city, last_name, first_name, business_name, last_service, customers.type AS customer_type FROM customers, generators
WHERE customers.id = generators.customer_id
AND generators.track_service='yes'
OR generators.flag='on'
ORDER BY generators.flag, generators.last_service, customers.last_name, customers.business_name";So I put in "AND generators.track_service='yes'", but if there is a problem win any generator we need it to also show up on the top of the list, so I did "OR generators.flag='on'"
The problem is whenever there is a generator with the "flag" set to on the quarry shows all records in the BD?