Confused on why I am getting a syntax error when writing my where clause?

I have to create two queries. In the first query I must select all the rows in Illinois, Indiana, Wisconsin, and Michigan. I am confused on why I am getting a syntax error when I try to write my select statement. Dealerships is the table being referenced. Can anyone please help?

select *
from dealerships
where state = 'IL','IN', 'WI', 'MI'

>Solution :

A column can’t simultaneously equal four different values. You’re looking for the IN clause:

SELECT * FROM dealerships WHERE state IN ('IL','IN','WI','MI')

If you were to write this much more verbosely to specifically use the = operator (just for demonstration purposes), it would be:

SELECT * FROM dealerships WHERE state = 'IL'
  OR state = 'IN'
  OR state = 'WI'
  OR state = 'MI'

Leave a Reply