gpt4 book ai didi

mysql - CASE 内部更新 (MySQL)

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

我有两个问题第一:

SELECT
players.username AS username,
tmp_player_operations.id AS tmp_id,
tmp_player_operations.operation_type AS operation_type,
tmp_player_operations.veryfication_code AS veryfication_code,
tmp_player_operations.expiration_date AS expiration_date,
tmp_player_operations.used AS used
FROM
players LEFT OUTER JOIN tmp_player_operations
ON players.id = tmp_player_operations.player_id
WHERE
tmp_player_operations.veryfication_code = '3c3c4375086fbcbc1cef938a0bfabbb9'

第二个:

UPDATE 
players LEFT JOIN tmp_player_operations
ON players.id = tmp_player_operations.player_id
SET
tmp_player_operations.used = 1,
players.active = 1
WHERE
tmp_player_operations.id = 8

现在我想在选择中进行此更新,我的意思是:

(CASE
WHEN
tmp_player_operations.used = 0
THEN
UPDATE....
AND 'updated'
ELSE
'not updated'
END) AS something

这样的事情可能吗?

最佳答案

不,这不可能。查询可以是 SELECTUPDATE,但不能同时是两者。

我想,您可以使用存储过程调用一个数据库来执行更新和选择,但这实际上仍然是两个查询(但该应用程序只会看到一个,即存储过程调用) . Chapter 18 of the MySQL manual有存储过程的详细信息。

也许您应该退后一步,问我们如何实现您的实际目标?

关于mysql - CASE 内部更新 (MySQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1281370/

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