I have a MySQL query, where I want to get a value, lets say m that can be ‘x’, ‘y’ or ‘z’ and two other variables which need to be exact values. I don’t know how to write this.
I don’t know if you get the idea, but this is what I have:
SELECT * FROM respuestas
WHERE id_curso = '155' OR id_curso = '156' OR id_curso= '157' OR id_curso= '158'
AND id_pregunta='1' AND respuesta>=0
So I need id_curso to be 155 or 156 or 157 or 158 and at the same time, id_pregunta = 1 and respuesta > 0.
I know this is not the way to write it, but I don’t know the right way.
Try this:
Or, if you prefer your verbose way, use a parenthesis:
If id_curso is an integer (which it doesn’t seem to be by your query since you’ve used quotation marks, but here goes anyway), you can even use the BETWEEN keyword to select a range of values: