2

I need to have MySQL query like this one:

UPDATE table_name
SET
    1 = 1
WHERE
    ID = 257

But I got the syntax 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 '1 = 1 
WHERE ID = 257' at line 3

Need to perform an UPDATE query without updating anything. What are the solutions?

4
  • what is purpose of running query without updating anything? Mysql will not allow u to do this Commented Mar 4, 2010 at 22:07
  • @Andrey: -1. While I've never had the need to just run a no-op query by itself, it's quite common to do this with INSERT .. ON DUPLICATE... queries. Commented Mar 4, 2010 at 22:09
  • Presumably, he wants a trigger to be triggered, or perhaps auditing to occur. Commented Mar 4, 2010 at 22:09
  • ok, but what is purpose of this query? Commented Mar 4, 2010 at 22:10

2 Answers 2

6
UPDATE `table_name`
SET `ID` = `ID`
WHERE `ID` = 257
Sign up to request clarification or add additional context in comments.

Comments

1

How about:

UPDATE table_name
SET
    ID = 257
WHERE
    ID = 257

Would that work for you?

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.