DELETE
FROM 014_terms
WHERE term_id IN (SELECT term_id
FROM 014_term_taxonomy
WHERE taxonomy LIKE 'pa_%');
I get an error
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘WHERE term_id IN (SELECT term_id FROM 014_term_taxonomy WHERE taxonomy LIKE ‘…’ at line 1
NOTE: I am using a plain text editor and the spaces are just plain spaces.
I am using phpMyAdmin and I have tried different variations of the query wrapping the table name in single quotes, like this :
SQL query:
DELETE FROM '014_terms' WHERE term_id IN (SELECT term_id FROM '014_term_taxonomy' WHERE taxonomy LIKE 'pa_%')
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''014_terms' WHERE term_id IN (SELECT term_id FROM '014_term_taxonomy' WHERE t...' at line 1
and this
SQL query:
DELETE FROM '014_terms' WHERE term_id IN (SELECT term_id FROM 014_term_taxonomy WHERE taxonomy LIKE 'pa_%')
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''014_terms' WHERE term_id IN (SELECT term_id FROM 014_term_taxonomy WHERE tax...' at line 1
2
Answers
The final solution was to use backticks to wrap the table names that begin with a numerical prefix like this. Thanks to @PaulT.
Thanks to everyone who provided feedback!!
:-)
The problem in your case seems like the table name starting from numbers/digits.
Try updating your
sql_mode
:After the above change, try executing your query.