正确的mySQL语法,从哪里删除。

时间:2021-05-18 09:07:27

I have a database with a table with 18 columns, the second of which is called "desc". I want to delete every row that has a certain value under "desc". I'm using this code:

我有一个包含18列的数据库,第2列称为desc。我想删除所有在desc下有特定值的行。我用这段代码:

DELETE FROM items WHERE desc='Swap this note at any bank for the equivalent item.'

Using this command inside of PHPMYADMIN gives me this error:

在PHPMYADMIN中使用这个命令会产生以下错误:

#1064 - 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 'desc='Swap this note at any bank for the equivalent item.'' at line 1

I've looked around pretty well but I can't seem to find what I'm doing incorrectly.

我环顾四周,似乎找不到我做错的事情。

mySQL version is 5.5, phpMyAdmin version is 3.4.5.

mySQL版本为5.5,phpMyAdmin版本为3.4.5。

3 个解决方案

#1


4  

You'll need to use backticks around desc as it is the keyword for descending order when using ORDER BY:

使用order BY时,需要在desc周围使用回勾,因为它是降序的关键字:

DELETE FROM items 
WHERE `desc`='Swap this note at any bank for the equivalent item.' 

#2


0  

Notice the back ticks. desc is a keyword in MySQL

发现蜱虫。desc是MySQL中的关键字

DELETE FROM items WHERE `desc`='Swap this note at any bank for the equivalent item.'

#3


0  

desc is a RESERVED WORD in MySQL

desc是MySQL中的一个保留词

in order to escape Reserved Words, you must use back tick ( ` )

为了避免保留词,必须使用后勾号(')

DELETE FROM `items` 
WHERE `desc`='Swap this note at any bank for the equivalent item.' 

#1


4  

You'll need to use backticks around desc as it is the keyword for descending order when using ORDER BY:

使用order BY时,需要在desc周围使用回勾,因为它是降序的关键字:

DELETE FROM items 
WHERE `desc`='Swap this note at any bank for the equivalent item.' 

#2


0  

Notice the back ticks. desc is a keyword in MySQL

发现蜱虫。desc是MySQL中的关键字

DELETE FROM items WHERE `desc`='Swap this note at any bank for the equivalent item.'

#3


0  

desc is a RESERVED WORD in MySQL

desc是MySQL中的一个保留词

in order to escape Reserved Words, you must use back tick ( ` )

为了避免保留词,必须使用后勾号(')

DELETE FROM `items` 
WHERE `desc`='Swap this note at any bank for the equivalent item.'