mysql - "Insert into where"语句错误

标签 mysql

我有一个 mysql 查询不断返回错误

错误:

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 ' iOS= 0, Android= 0, sport IN (football,tennis,' at line 2

整个查询是

INSERT INTO table2
SELECT *
FROM table1
WHERE iOS = 0
    , android = 0
    , sport IN (football,tennis,golf)

(iOS 和 android 列是 bool 值,sport 是 VARCHAR)

查询旨在获取 iOS/android 列为 0 且运动列值为足球、网球或高尔夫的所有条目。

错在哪里?感谢您的帮助

最佳答案

使用 ANDOR 包含更多条件。

文字字符串使用引号分隔:

INSERT INTO table2
SELECT * FROM table1
WHERE iOS = 0
AND android = 0
AND sport IN ('football', 'tennis', 'golf')

关于mysql - "Insert into where"语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27059101/

相关文章:

mysql - 如何一起显示表格和总成本?

java - 如何设置默认数据库值

php - 想要通过product_id搜索并获取表单字段中基于product_id的所有数据

php - PHP 中的 ispostback(.NET) 等价物是什么?

Mysql查询问题

mysql - 两个主键

mysql - 无法将 csv 保存到本地文件夹 [MySQL]

php - 从数据库中选择随机项目

mysql - 对数据进行分组时选择特定行

java - 简单的 HTML 无法从 servlet (java) + mysql 获取 JSON