在 MySQL 列中搜索多个值
Searching for multiple values in MySQL column
我正在尝试使用 dbForge 来测试一些查询。我有一个名为 (test) 的数据库,table 名为 (crimes)。我想 select 在(描述)列中具有特定值的所有行。
SELECT * FROM crimes
WHERE `Description` = ('AGGRAVATED: HANDGUN'), ('ARMED: HANDGUN')
此 returns 语法错误:
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
使用IN
运算符指定多个值来匹配一个条件:
SELECT * FROM crimes
WHERE `Description` IN ('AGGRAVATED: HANDGUN', 'ARMED: HANDGUN')
我正在尝试使用 dbForge 来测试一些查询。我有一个名为 (test) 的数据库,table 名为 (crimes)。我想 select 在(描述)列中具有特定值的所有行。
SELECT * FROM crimes
WHERE `Description` = ('AGGRAVATED: HANDGUN'), ('ARMED: HANDGUN')
此 returns 语法错误:
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
使用IN
运算符指定多个值来匹配一个条件:
SELECT * FROM crimes
WHERE `Description` IN ('AGGRAVATED: HANDGUN', 'ARMED: HANDGUN')