I'm having a question concerning a mysql query.
What I want to achieve is the to write a query that says:
SELECT *
FROM Table
WHERE Col1 = 'something' AND Col2 = 'something' AND
( Col3 = 'Something' OR Col3 = 'Something');
So it looks the same as you whould use conditional statements in php: (notice the braces around the or ;) )
if ( $i == 'something' and ($k == 'something' || $k == 'something') ){
//Do something
}
or maybe there is another/better way to do that?
(EDIT) I know now that the query is correct. Thank you for confirming that to me. Below is part of the query that keeps failing.
SELECT *
FROM Table
WHERE Condition1 = 'something'
AND(
Enddate = DATE(DATE_ADD(NOW(), INTERVAL -1 DAY))
OR
Enddate = DATE(DATE_ADD(NOW(), INTERVAL -2 DAY))
)
Probably something obvious but I can't seem to find it.
(SOLVED)
Hey sorry for the question. I just figured out that the query mist a closing brace somewhere just after the above code.
Instead of writing OR
conditions, you can use IN
clause
SELECT *
FROM Table
WHERE Col1 = 'something1' AND
Col2 = 'something2' AND
Col3 IN('Something3','Something4');
SELECT *
FROM Table
WHERE Condition1 = 'something'
AND(
Enddate = DATE(DATE_ADD(NOW(), INTERVAL -1 DAY))
OR
Enddate = DATE(DATE_ADD(NOW(), INTERVAL -2 DAY))
)
no need for "as kuur"