Can we write conditions using both AND and OR?

Hello @sarahtlv,

Welcome to the forums!

Between the two choices presented above, the first one should be used.

An alternative would be to use the IN operator:

SELECT * 
FROM movies
WHERE genre IN ('action', 'comedy', 'romance')

You can read more about it here: IN Operator

4 Likes

I wonder if we can write this query shorter than it is works (without repeating word “genre”)
Instead of:
SELECT *
FROM movies
WHERE genre LIKE ‘romance’
OR genre LIKE ‘comedy’;

This:
SELECT *
FROM movies
WHERE genre LIKE ‘romance’
OR ‘comedy’;

Just to be clear, isn’t the question asking if we can combine both AND and OR operators? The AND in you example is AND used to specify range BETWEEN 10 AND 20 and also BETWEEN 50 AND 60 , no?

do you know html can you help me thanks

Unsure why you are asking this question here.
Please look in the proper forum threads for help regarding HTML, this is an SQL thread.
Besides that, when you ask a question please ask a specific question and give examples or the code you are working on so that people can help you better
Good luck

PUT SPACES IN YOUR CODE WHERE NEEDED. MAINTAIN READABILITY. SMH.

I tried this and sadly it didn’t work. Nice idea tho

Why cannt I just write like this

SELECT *
FROM movies
WHERE genre = 'romance'  OR  'comedy';

That’s the syntax for the condition.

WHERE genre = 'romance' OR genre = 'comedy'

Alternative:

WHERE genre IN ('romance', 'comedy')
1 Like