0

I have problem with my SQL Server query:

UPDATE latihan AS t1 ,
       (SELECT Equipment, system_status, functloc 
        FROM latihan 
        WHERE system_status='ESTO') AS t2 
SET t1.functloc = t2.functloc
WHERE t1.supereq = t2.equipment

I just want update the functloc on equipment based functloc on supereq.

The error is:

[Err] 42000 - [SQL Server]Incorrect syntax near the keyword 'AS'.
42000 - [SQL Server]Incorrect syntax near the keyword 'AS'.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Tri
  • 25
  • 1
  • 9

1 Answers1

1

I think you want something like this:

update t1 set
  functloc = t2.functloc
from latihan t1
inner join (
  select Equipment, system_status, functloc
  from latihan
  where system_status='ESTO'
) t2 on t2.equipment = t1.supereq
Dale K
  • 25,246
  • 15
  • 42
  • 71