Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading