Php 用于DELETE、FROM、WHERE的正确mySQL语法
我有一个数据库,其中一个表有18列,第二列叫做“desc”。我想删除“desc”下具有特定值的每一行。我正在使用以下代码:Php 用于DELETE、FROM、WHERE的正确mySQL语法,php,mysql,sql,database,phpmyadmin,Php,Mysql,Sql,Database,Phpmyadmin,我有一个数据库,其中一个表有18列,第二列叫做“desc”。我想删除“desc”下具有特定值的每一行。我正在使用以下代码: DELETE FROM items WHERE desc='Swap this note at any bank for the equivalent item.' 在PHPMYADMIN中使用此命令会导致以下错误: #1064 - You have an error in your SQL syntax; check the manual that correspond
DELETE FROM items WHERE desc='Swap this note at any bank for the equivalent item.'
在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
我环顾了一下四周,但似乎找不到我做得不对的地方
mySQL版本为5.5,phpMyAdmin版本为3.4.5。您需要在
desc
周围使用反勾号,因为在使用按顺序时,它是降序的关键字:
DELETE FROM items
WHERE `desc`='Swap this note at any bank for the equivalent item.'
注意后面的滴答声。desc是MySQL中的一个关键字
DELETE FROM items WHERE `desc`='Swap this note at any bank for the equivalent item.'
desc
是MySQL中的
为了转义保留字,必须使用反勾选(`)
工作得很好,我没看到。谢谢你的帮助。我不会删除任何行,但是语法很好,所以我将看看我在其他方面做错了什么。谢谢你的解答。尽管你说back tick,我还是用了一个撇号。现在一切正常。谢谢你的解决方案。
DELETE FROM `items`
WHERE `desc`='Swap this note at any bank for the equivalent item.'