0

Is there any way to simplify this expression?

UPDATE `app01`.`ost_user` SET `org_id` = '2' WHERE `ost_user`.`id` = 6;
UPDATE `app01`.`ost_user` SET `org_id` = '2' WHERE `ost_user`.`id` = 7;
UPDATE `app01`.`ost_user` SET `org_id` = '2' WHERE `ost_user`.`id` = 8;

I was thinking in something like:

UPDATE `app01`.`ost_user` SET `org_id` = '2' WHERE `ost_user`.`id` = [6, 7, 8];

Is there any way?

I've already tried to find an answer to this question, but I dont even know which terms should I search...

dot.Py
  • 5,007
  • 5
  • 31
  • 52
  • 1
    Seems like you want the `in` operator - `UPDATE \`app01\`.\`ost_user\` SET \`org_id\` = '2'' WHERE \`ost_user\`.\`id\` in (6,7,8);` - Be aware there can be pitfalls there multiple IDs - see [this response](http://stackoverflow.com/questions/9736284/mysql-where-in) for more info. – zzevannn Oct 22 '15 at 19:20

1 Answers1

2

try with

UPDATE `app01`.`ost_user` SET `org_id` = '2' WHERE `ost_user`.`id` in (6, 7, 8);
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107