Home > OS >  MYSQL: encounter ERROR 1064 when trying to delete row
MYSQL: encounter ERROR 1064 when trying to delete row

Time:07-07

when i execute following command, it can print some records

mysql> select *  from table_name where domain like "%com";
 --------------------- -------------- -------------------- ----------- ---------- 
| date                | domain       | percent            | flow1     | flow2    |
 --------------------- -------------- -------------------- ----------- ---------- 
| 2021-10-13 21:00:00 | www.a.com    |                 20 |    544.93 |      109 |
| 2022-05-26 21:00:00 | www.b.com    |              23.28 |     64.81 |    15.09 |

but when i execute delete, it print some error

mysql> delete  from table_name where domain like "%com";
ERROR 1064 (HY000): Where clause should be compound or binary predicate

what is the mean of above error? and how to solve it.

Thanks in advance!

CodePudding user response:

The error message for error 1064 on MySQL server have the next pattern:

%s near '%s' at line %d

See Server Error Message Reference.

You receive another message text - hence it is not produced by MySQL. Either your DBMS is not MySQL or the error message printed is an interpretation of the MySQL error message made by the client.

  1. Ensure that your DBMS is MySQL really. Execute SELECT VERSION(); and provide complete output for this command.
  2. Ensure that you use command-line client mysql.exe installed as a part of MySQL server installation, and not another tool which looks like CLI.

Additionally - show the output for SELECT SESSION sql_mode;.

CodePudding user response:

The issue is likely the double quotes you used for the string literal following LIKE. This may spoof MySQL into thinking that you are trying to refer to a column by that name. Instead, always use single quotes for string literals:

DELETE
FROM table_name
WHERE domain LIKE '%com';
  • Related