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 ([EMAIL PROTECTED])
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to