How to compare values of two columns in a WHERE clause?

In SQL, I was learning about the WHERE clause as part of Queries. WHERE clause can be used to compare values of two columns.

I tried running the following code where as I wanted a list of movies whose id and imdb_rating are greater than 5.

SELECT id, imdb_rating

FROM movies

WHERE id, imdb_rating > 5;

This is not fetching any results.

But, when I altered the code to

SELECT id, imdb_rating

FROM movies

WHERE id > 5;

The results were still focussed on only one column. What am I doing wrong?

You could use where condition1 or condition2. you can use or or and keyword to check for multiple conditions

and means both conditions need to be met, while or only needs one of the conditions needs to be met

1 Like

Thank you so much for your reply! :smiley: