Reputation: 738
I have an mysql query that keeps coming back with an error
Error:
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
The whole query is
INSERT INTO table2
SELECT *
FROM table1
WHERE iOS = 0
, android = 0
, sport IN (football,tennis,golf)
(iOS and android columns are boolean values and sport is a VARCHAR
)
The query is meant to get all entries where the iOS/ android columns are 0 and the sports column value is either football or tennis or golf.
Where's the mistake? Thanks for any help
Upvotes: 0
Views: 63
Reputation: 627
Your WHERE
statement is wrong. You have to add the AND
condition between clauses.
WHERE iOS = 0 AND android = 0 AND sport IN ('football', 'tennis', 'golf')
Upvotes: 1
Reputation: 424983
More onditions are included using AND
or OR
.
Literal Strings are delimited using quotes:
INSERT INTO table2
SELECT * FROM table1
WHERE iOS = 0
AND android = 0
AND sport IN ('football', 'tennis', 'golf')
Upvotes: 2
Reputation: 88
just type and insted of ,(comma) and write sports name in single quote
INSERT INTO table2 SELECT * FROM table1 WHERE `iOS` = 0 and android = 0 and (sport IN ('football','tennis','golf'))
Upvotes: 1