티스토리 뷰

공부

[MySQL] update by multiple condition

seunggabi 승가비 2020. 4. 26. 02:47
UPDATE table_users
    SET cod_user = (case when user_role = 'student' then '622057'
                         when user_role = 'assistant' then '2913659'
                         when user_role = 'admin' then '6160230'
                    end),
        date = '12082014'
    WHERE user_role in ('student', 'assistant', 'admin') AND
          cod_office = '17389551';

https://stackoverflow.com/questions/25674737/mysql-update-multiple-rows-with-different-values-in-one-query/25674827

 

MySQL - UPDATE multiple rows with different values in one query

I am trying to understand how to UPDATE multiple rows with different values and I just don't get it. The solution is everywhere but to me it looks difficult to understand. For instance, three upda...

stackoverflow.com

 

'공부' 카테고리의 다른 글

[Python] counter  (0) 2020.04.26
[Git] pull & push don't ask password  (0) 2020.04.26
[MySQL] update by multiple condition  (0) 2020.04.26
[Python] split string to char  (0) 2020.04.26
[Maven] MissingProjectException  (0) 2020.04.26
[Java] Spring Boot jar  (0) 2020.04.26
댓글
댓글쓰기 폼