Rick James Wrote:
-------------------------------------------------------
> First, let's get on the same page for punctuation
> terminology:
> [] - brackets (or "square brackets")
> {} - braces (or "curly brackets")
> <> - angle brackets
> () - parentheses -- but not "brackets"
>
> x AND y OR z is the same as (x AND y) OR z
> x OR y AND z is the same as x OR (y AND z)
> That is, without parentheses, AND has precedence
> over OR. If in doubt, add parens.
>
> Your second example probably needed more parens.
Sorry for my bad english, I didnt know better, but I know how the logic of standard operators works, the only reason why it was without correct "parens", was that it comes from a php script, which isnt really easy to overview, if I dont exactly know how to handle this kind of statement..
Peter Brawley Wrote:
-------------------------------------------------------
> Simplifying your table & column names for human
> readability and less typing ...
thanks, I did like this, because I read somewhere that I should keep the names to the related tables..
the values in the properties and labels are id's from another table?!
but I would be happy about any advice
Peter Brawley Wrote:
-------------------------------------------------------
>
>
> would require that columns have two different
> values simultaneously---obviously not possible. So
> we need to clarify your requirement. You want the
> id_marketplace values for which ...
->> obviously not possible.
That was my propblem, Ive never worked with Joins or Group
These ways what you wrote wasnt that what I searched, but I tried a bit with Join
and I got the solution for this statement...
SELECT a.id_marketplace
FROM marketplace_properties_used a
JOIN marketplace_properties_used b
ON a.id_marketplace=b.id_marketplace AND
((a.id_marketplace_properties_label=6 AND a.id_marketplace_properties=35)
OR (a.id_marketplace_properties_label=6 AND a.id_marketplace_properties=5) )
AND b.id_marketplace_properties_label=7 AND b.id_marketplace_properties=7;
which is
+----------------+
| id_marketplace |
+----------------+
| 11 |
| 13 |
+----------------+
But my question now, what if I want to add another filter, it should be like this, if I add the same label, it should be OR and if its different, it should be AND, like ( label = 6 AND properties = 35 OR labgel = 6 AND properties = 5 ) AND ( label = 7 AND properties = 7 )
so if I add a label 7 with properties 8 it should be like this
( label = 6 AND properties = 35 OR labgel = 6 AND properties = 5 ) AND ( label = 7 AND properties = 7 OR label = 7 AND properties = 8 )
But is this going to work like this?
Or how would you do this?
It has to be variable, it will come from a PHP script, with variable number of filters can be more than 2 or 3 ?!
I hope you understand what I mean, again sorry for my bad english and thanks for your help !