Re: Problem with SQL query :(
Rick James Wrote:
-------------------------------------------------------
> > ( label = 6 AND properties = 35 OR label = 6 AND
> properties = 5 ) AND ( label = 7 AND properties =
> 7 OR label = 7 AND properties = 8 )
>
> is the same as
> ( label = 6 AND properties IN (35,5) ) AND
> ( label = 7 AND properties IN (7,8) )
>
sounds good
> But both are probably _wrong_??
no its not wrong, for better understanding..
I've a product like a Phone, it's ID is id_marketplace
Then the phone can have different properties which are saved in other tables, and just the ID's are used, for example
Label: Color ( ID: 1 )
Properties: White ( ID: 1 ), Black ( ID:2 ), Gray ( ID: 3 )
Label: Simlock ( ID: 2 )
Properties: Telering ( ID: 4), Vodafone ( ID: 5 )
so now, I want a filter, where I can multiselect each Propertie, like:
I want Phone that is White OR Gray, would mean:
( label = 1 AND properties IN (1,3) ) ---> if its an OR
Then I would like for example:
I want a Phone that is WHITE OR GRAY and it should have Simlock for Telering or Vodafone
so
( label = 1 AND properties IN (1,3) ) AND ( label = 2 AND properties IN (1,2) )
Would that work like this?
And with more like properties IN ( 1,2,3,4,5 ) ??
Then its no problem anymore :)
I hope you understand now better, so in my table there are a lot of multiple id_marketplace, properties and labels, cause they are just id's, and every product's properties are listed in this table!
> Note that ANDing two filters can only shrink the
> number of rows in the result; ORing two filters
> can only increase the number of rows.
Thats what I want ..