skip to Main Content
UPDATE accounts 
SET lastSerialChange = CURRENT_TIMESTAMP 
WHERE username = 'Jayden';

UPDATE accounts 
SET serialChanges = '[{"serial":"D06ACE5BBE90E803590D1691FB9254B3","reason":"test","date":1695495618004}]' 
WHERE username = 'Jayden';

INSERT INTO serial_requests 
(username, serial, reason, requestedAt) 
VALUES  ('Jayden',
'D06ACE5BBE90E803590D1691FB9254B3',
'test',
1695495618004);

I am querying my database with the above, I believe correct syntax, but I get an error saying:

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 'UPDATE accounts SET serialChanges = '[{"serial":"D06ACE5BBE90E803590D1691FB9254B' at line 2

I have been trying to debug this for a long time but I just can’t identify what the problem is with my syntax.

2

Answers


  1. Chosen as BEST ANSWER

    The problem was that I tried to execute three seperate SQL statements at once. As soon as I made these 3 different queries it worked.


  2. Have you tried to compile the string
    '[{"serial":"D06ACE5BBE90E803590D1691FB9254B3","reason":"test","date":1695495618004}]'
    into a variable and then use that in the actual update statement?

    Also, please post the schema of the accounts table. Is there a chance you could alter the schema into a higher normal form? I can’t see why one would like to put three properties into one column instead of three.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search