gpt4 book ai didi

mysql - 请帮助将 4 个 MySQL 查询合并为一个

转载 作者:行者123 更新时间:2023-11-29 09:16:36 25 4
gpt4 key购买 nike

UPDATE RIA.Contact SET title = REPLACE(title, 'Cheif', 'Chief') where title rlike 'Cheif';
UPDATE RIA.Contact SET title = REPLACE(title, 'Manger', 'Manager') where title rlike 'Manger';
UPDATE RIA.Contact SET title = REPLACE(title, 'Manging', 'Managing') where title rlike 'Manging';
UPDATE RIA.Contact SET title = REPLACE(title, 'Excutive', 'Executive') where title rlike 'Excutive';

我们可以将上面的 4 个合并为这样的内容吗:UPDATE table SET A = IF(A > 0 AND A < 1, 1, IF(A > 1 AND A < 2, 2, A)) WHERE A IS NOT NULL;

我知道我们可以使用过程来做到这一点,但是是否可以仅使用查询?

我试过了 -

UPDATE RIA.Contact SET title = IF(title rlike 'Cheif', replace(title,'Cheif','Chief'), IF(title rlike 'Manger', replace(title,'Manger','Manager'))) WHERE title rlike 'Cheif' or title rlike 'Manger';

不许走!

最佳答案

UPDATE RIA.Contact
SET title = REPLACE(
REPLACE(
REPLACE(
REPLACE(title, 'Excutive', 'Executive'),
'Manging', 'Managing'),
'Manger', 'Manager'),
'Cheif', 'Chief')
WHERE title rlike 'Cheif'
OR title rlike 'Manger'
OR title rlike 'Manging'
OR title rlike 'Excutive';

关于mysql - 请帮助将 4 个 MySQL 查询合并为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3944117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com