Re: PHP | MySQL Search
| From: | David Bouw | Date: | Tue, 13 Mar 2001 19:01:38 +0000 |
| Subject: | Re: PHP | MySQL Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43698@lists.php.net to get a copy of this message | ||
Hi there..
Try:
SELECT HouseID FROM Search WHERE (CountryID='2' AND PriceID='3' OR
(FacilityID='1' OR FacilityID='5'))
The extra brackets are only to make it easier to read.. (For me it is..)
What you basically asked where all records in which CountryID is 2 and
PriceID is 3 AND (only) where the facilityID is 1 or 5..
But you want everything with CountryID is 2 and PriceID is 3 OR when the
facilityID is 1 or 5
Hope this helps..
Bye Bye
David
> Hya'll,
>
> I've got a little problem with coding some php/mysql, this is what I have
:
>
> ---------------------------------------------------------------------
> Table Search
> ---------------------------------------------------------------------
> HouseID | FacilityID | SurroundingID | PriceID | TypeID | CountryID |
> ---------------------------------------------------------------------
> 1 | 1 | 0 | 3 | 4 | 2 |
> 1 | 3 | 0 | 3 | 4 | 2 |
> 1 | 5 | 0 | 3 | 4 | 2 |
> 1 | 0 | 3 | 3 | 4 | 2 |
> 2 | 0 | 0 | 3 | 5 | 2 |
> 2 | 0 | 1 | 3 | 5 | 2 |
> 2 | 5 | 0 | 3 | 5 | 2 |
> ---------------------------------------------------------------------
>
> Query 1 :
>
> (I only want result on houses which are in country 2 and in price 3 and
> facility 1 must be included on the spot)
>
> I've used :
>
> SELECT HouseID FROM Search WHERE CountryID='2' AND PriceID='3' AND
> (FacilityID='5')
>
> Result 1 :
>
> HouseID 1 and HouseID 2 this one is right.
>
> Query 2 :
>
> (I only want result on houses which are in country 2 and in price 3 and
> facility 1 and 5 must be included on the spot)
>
> I've used :
>
> SELECT HouseID FROM Search WHERE CountryID='2' AND PriceID='3' AND
> (FacilityID='1' OR FacilityID='5')
>
> Result 2 :
>
> again HouseID 1 and HouseID 2, the problem here is that HouseID 2 doesn't
> contain Facility 1.
>
> The problem here is just that when I give more criteria to the query the
> result is or equal or even bigger then when I give less criteria, it
should
> be just the other way around, that is I want a more detailed result, does
> anyone have the solution for this problem ?
>
>
> A. Boontjes aka Tuin (Tuin@TomDeeDom.com)
> Web-developer at : www.TomDeeDom.com & www.Impression.nl
>
> --
> Hi! I'm a .signature virus! Copy me into your ~/.signature to help me
> spread!
> --
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>