Search code examples
mysqlsqlsql-in

Searching for multiple values in MySQL column


I am trying to use dbForge to test a few queries. I have a database named (test) and the table is named (crimes). I want to select all rows that have specific values in the (Description) column.

SELECT * FROM crimes
WHERE `Description` = ('AGGRAVATED: HANDGUN'), ('ARMED: HANDGUN')

This returns error in the syntax:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ('ARMED: HANDGUN')' at line 2


Solution

  • Use IN operator to specify multiple values to match a condition:

    SELECT * FROM crimes
    WHERE `Description` IN ('AGGRAVATED: HANDGUN', 'ARMED: HANDGUN')