0

Trying to update a mysql employee table where the Group column if it contains the word staff it changes the contents of the column to a 4. What am I doing wrong?

UPDATE employee SET Group = "4" WHERE Group LIKE "Staff";

2 Answers 2

3

GROUP is a reserved word. Quote it with backticks:

UPDATE employee SET `Group` = "4" WHERE `Group` LIKE "Staff";
Sign up to request clarification or add additional context in comments.

Comments

1

You need to quote the reserved word GROUP

if it contains the word staff

and wildcard operators % around LIKE to match any instance, not just the whole string (LIKE without wildcards is equivalent to =).

UPDATE employee SET `Group` = "4" WHERE `Group` LIKE "%Staff%";

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.