0

I have a simple database query that I can not figure out for some reason.

DELETE * FROM Wishlist WHERE (id, uid) VALUES ("18","34i274o1y24ouy1o4");

This might be just wrong syntax in general. My skills are pretty low when it comes to databases. Any ideas? Just trying to delete a row.

Thanks in advance!

4 Answers 4

2

It looks like you were trying to use the INSERT syntax to do a deletion. If you want to remove records with the criteria you gave try this:

DELETE
FROM Wishlist
WHERE id = '18' AND uid = '34i274o1y24ouy1o4'
Sign up to request clarification or add additional context in comments.

4 Comments

DELETE * FROM Wishlist WHERE id = "18" AND uid = "34i274o1y24ouy1o4"; is throwing an syntax error
What is the error? I just changed to use single quotes, but this should not matter.
Error: ER_PARSE_ERROR: 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 '* FROM Wishlist WHERE id = "18" AND uid = "34i274o1y24ouy1o4"' at line 1
Kill the * ... the syntax is DELETE FROM WishList
1

You should use IN:

DELETE FROM Wishlist WHERE (id, uid) IN ('18','34i274o1y24ouy1o4');

Or just use AND:

DELETE FROM Wishlist WHERE id = '18' AND uid = '34i274o1y24ouy1o4';

Comments

1
DELETE FROM Wishlist WHERE id = '18' AND uid = '34i274o1y24ouy1o4';

Comments

1

In addition to other answers using IN keyword,
DELETE FROM Wishlist where id='18' and uid = '34i274o1y24ouy1o4' also works.
NOTE that you do not need asterisk in DELETE operation.

If id is the primary key, where id = '18'without uid should be enough.
Also, you might want to consider making id an auto increment column with type INT. It is faster to query and you can get rid of the quotes like where id = 18.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.