Just wanted to let you know that your advice worked like a charm! Thanks so much!
Ali
Neil Smth wrote:
At 01:11 31/12/2003 +0000, you wrote:
To: php-db@xxxxxxxxxxxxx Message-ID: <3FF1B61E.5070909@xxxxxxxxxxx> Date: Tue, 30 Dec 2003 12:30:06 -0500 From: Ali Van Doren <alikat@xxxxxxxxxxx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Categories and Items query
<snip>
$query = "SELECT category, feature_description FROM features as f, feature_categories as fc WHERE f.feature_category_id=fc.feature_category_id AND f.featureset_id = '1' OR f.featureset_id = '3' ORDER BY f.feature_category_id ASC";
<snip>
So, I actually have two questions: 1) Does anyone know why my query is misbehaving so badly?
I think it's because you need to put the OR statements in brackets, which will then return results with
.... AND (f.featureset_id = '1' OR f.featureset_id = '3' )
Where you are getting results more like ... AND f.featureset_id = '1' then *also asking* for additional results matching "f.featureset_id = '3' "
Do you see the difference in the way the SQL interprets your query ? Its quite subtle.
Anyway usually to avoid confusion in cases like this I would use the IN construct, its less verbose and you can construct an IN list by using PHP's join(",",featureset) function
.... AND f.featureset_id IN ( '1','3' )
Hope that helps. Neil.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php