0

I have problem with this syntax, here is my SQL Server query.

I want to set null to functloc column based on column supereq where system status='esto'

update ih08pkgmf as t1, 
       (select Equipment, `System status`, `Functional loc.` 
        from ih08pkgmf 
        where `System status` = 'ESTO' 
          and `Superord.Equip.` is null) as t2 
set t1.`System status` = t2.`System status`,
    t1.`Functional loc.` = t2.`Functional loc.` 
where 
    t1.`Superord.Equip.` = t2.Equipment`

Expected result is, all the equipment column where system='aseq' based on supereq system status='esto' the functloc is null

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Tri
  • 25
  • 1
  • 9
  • Please [format](http://sqlformat.org/) your query. Is this MySQL or SQL Server? [update](https://dev.mysql.com/doc/refman/5.7/en/update.html) allows `table references` at the start which isn't the same as subqueries. – danblack Dec 03 '18 at 04:53
  • If it is MySQL, the solution could be https://stackoverflow.com/questions/2114534/mysql-syntax-for-join-update/2114583 and if it is SQL Server, https://stackoverflow.com/questions/982919/sql-update-query-using-joins will work for you – Harsh Shankar Dec 03 '18 at 05:09
  • **TYPO** alert: it's a **column** - not a "colomn" .... – marc_s Dec 03 '18 at 06:16
  • @danblack im using sql server, and this is query for mysql local, can you tell me sql server query? – Tri Dec 03 '18 at 07:01
  • Nope - you are not using sql server. The backtick cannot be used in tsql as an object name delimiter. However, Harsh has posted links for both MySQL and TSQL. Learn the syntax, correct your errors. – SMor Dec 03 '18 at 13:36

0 Answers0