MySQL Forums
Forum List  »  PHP

Re: Problem with SQL query :(
Posted by: Sebastian Maur
Date: January 21, 2014 03:40PM

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 ..

Options: ReplyQuote


Subject
Written By
Posted
January 18, 2014 10:39PM
January 19, 2014 12:30PM
January 19, 2014 12:41PM
January 20, 2014 03:24PM
Re: Problem with SQL query :(
January 21, 2014 03:40PM
January 21, 2014 06:22PM
January 22, 2014 04:19PM
January 23, 2014 12:15AM
January 23, 2014 10:23AM
January 19, 2014 12:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.