Asking
Only logged in members can reply and interact with the post.
Join SimilarWorlds for FREE »

Anyone familiar with MySQL. Why DELETE FROM doesn't work but ;DELETE FROM works?

This page is a permanent link to the reply below and its nested replies. See all post replies »
Sharon · F
Most MySQL statements require a ; at the end. I'm guessing that initial ; is ending a previous statement. What is the full query you're trying to run?
Riemann · 31-35, M
Riemann · 31-35, M
Check pls @MartinTheFirst
Sharon · F
@Riemann

[quote]UPDATE mytable SET username="myuser" WHERE id=8
DELETE FROM mytable WHERE id=8[/quote]

The UPDATE line needs to end with a ';'. The reason ;DELETE... works is because it treats that initial ';' as the end of the previous line.

Change it to -
UPDATE mytable SET username="myuser" WHERE id=8;
DELETE FROM mytable WHERE id=8;

Some statements will work without a ';' at the end but it's best to always use one anyway.

It's also a good idea to enclose table and field names in backticks to avoid conflict with keywords of the same name. e.g.

UPDATE `mytable` SET `username` = "myuser" WHERE `id` = 8;
DELETE FROM `mytable` WHERE `id` = 8;