Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper mySQL syntax for DELETE, FROM, WHERE

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:

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:

#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.

like image 233
taylorthurlow Avatar asked Mar 23 '26 10:03

taylorthurlow


1 Answers

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

DELETE FROM items 
WHERE `desc`='Swap this note at any bank for the equivalent item.' 
like image 125
D'Arcy Rittich Avatar answered Mar 24 '26 22:03

D'Arcy Rittich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!