gpt4 book ai didi

mysql - "Insert into where"语句错误

转载 作者:太空宇宙 更新时间:2023-11-03 10:49:01 24 4
gpt4 key购买 nike

我有一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com