slopeofhope
slopeofhope

Reputation: 776

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

Upvotes: 1

Views: 58

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1269733

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.

Upvotes: 1

ScaisEdge
ScaisEdge

Reputation: 133360

You have a cs alias after ignore and (from) table name in wrong position and from in update is not present.

Could be this way

 update IGNORE 
 admin.ConfigSupplemental as cs        
 inner join admin.Config as cc on ( cs.ConsoleConfigID = cc.ID  and cs.Name = 'GetTime' and cc.Ctid = 200)
 set Value = '20934820843'
 ;

Upvotes: 1

Related Questions