slopeofhope slopeofhope - 1 year ago 61
SQL Question

what is wrong with below sql update query?

I am trying to run the following query

update IGNORE cs
set Value = '20934820843'
from admin.ConfigSupplemental as cs,
admin.Config as cc
where cs.ConsoleConfigID = cc.ID
and cs.Name = 'GetTime' and cc.Ctid = 200

I am getting the following exception:

Check the manual that corresponds to your MariaDB server version for
the right syntax to use near ConfigSupplemental as cs

I also tried the below as well but I get the same error.

update IGNORE cs
set cs.Value = '2039482094380'
from admin.ConfigSupplemental cs
join admin.Config cc on
cc.ID = cs.ConsoleConfigID
where cs.Name = "GetTime"
and cc.Ctid = 200

Answer Source

Here is the correct syntax for MySQL and MariaDB:

update admin.ConfigSupplemental cs join
       admin.Config cc
       on cs.ConsoleConfigID = cc.ID 
    set Value = '20934820843'
where cs.Name = 'GetTime' and cc.Ctid = 200;

You can add in the ignore if you really intend it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download