MYSQL update with WHERE SELECT subquery error

后端 未结 4 1303
时光取名叫无心
时光取名叫无心 2020-12-05 02:46

I have an issue with getting select sub-queries to work on an UPDATE. I\'m trying something like the following:

UPDATE foo
   SET bar=bar-1
 WHE         


        
4条回答
  •  一生所求
    2020-12-05 03:20

    In some cases you can also take advantage of the MySQL variable. e.g.:

    SET @id1 = (SELECT id FROM foo WHERE name = 'parent');
    UPDATE foo SET parent_id = @id1 WHERE name = 'emails';
    

提交回复
热议问题