Search code examples
mysqlis-empty

MySQL return output in empty set


I have movie as my table

I tried to execute the following queries where put in 2 conditions with movie_genre='comedy' and movie_genre='family':

select movie_title, movie_cost, movie_genre
from movie
where movie_genre ='comedy'
and movie_genre ='family'
order by movie_cost asc;

After executed the queries it return Empty set. While I tried one condition it works normally but when adding 2 conditions it goes wrong again.

How can I solve this problem?


Solution

  • You have to use OR to check if movie_genre is either of the two values.

    Updated query -

    select movie_title, movie_cost, movie_genre from movie
    where movie_genre ='comedy' or movie_genre ='family'
    order by movie_cost asc;