0

I have a table like this:

enter image description here

Why is this command not working:

UPDATE 'stitch' SET 'claim-time'='20' WHERE 'group'='010000'

I get the 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 ''stitch' SET claim-time='20' WHERE group='010000'' at line 1


Everything in the table is text.

user2351418
  • 381
  • 3
  • 5
  • 13

3 Answers3

1

group is a reserved keyword in mysql so use backticks to escape it

`group`

Also you are selecting the string as column name, correct format is

UPDATE `stitch` SET `claim-time`='20' WHERE `group`='010000'
Arun Killu
  • 13,581
  • 5
  • 34
  • 61
0

Try removing the single quotes from stitch, claim-time and group. Either leave them out or use backquote `. The comma is used for strings, not table and field names.

Also, I don't know what data type claim-time and group are. If they are numeric (int, bigint, etc) and not string (varchar, text, etc) then you'll need to remove the single quotes from those too.

update stitch set claim-time=20 where group='0100000'; # assuming group is a string data type

user2910265
  • 844
  • 1
  • 9
  • 15
0

Try this.

UPDATE TableName SET claim-time='20' WHERE group='010000';

That is considering if claim-time is a varchar datatype. If it's a number just remove the quotes.

Remember to avoid reserved names such as field names such as name, password, group, user and stuff just to be safe. Make it user1, group1 instead or something like these.

chris_techno25
  • 2,401
  • 5
  • 20
  • 32