gpt4 book ai didi

php - 在 2 个表中搜索唯一条目,然后更改数据

转载 作者:行者123 更新时间:2023-11-30 01:30:18 25 4
gpt4 key购买 nike

目标是在两个相似的表中搜索单行数据。

UPDATE
regusers_test AS rt
INNER JOIN
alt_toon_test AS att
ON
att.`toonname` = rt.`toonname`
SET
rt.`server` = CASE WHEN rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' THEN '$server' ELSE rt.`server`
att.`server` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$server' ELSE att.`server`
WHERE
(
rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon'
)
OR
(
att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon'
)

但我不断得到:

You have an error in your SQL syntax; check the manual that corresponds to your mySQL server version for the right syntax to use near 'att.'server'=Case When att.'username'='$user'...

我在周末进行了大量的谷歌搜索,但找不到解决方案。希望这里有人知道发生了什么。

最佳答案

SET 需要在作业之间添加 , 。

编辑修正了您的查询:

UPDATE
regusers_test AS rt
INNER JOIN
alt_toon_test AS att
ON
att.`toonname` = rt.`toonname`
SET
rt.`server` = CASE WHEN rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' THEN '$server' ELSE rt.`server`,
att.`server` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$server' ELSE att.`server`
WHERE
(
rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon'
)
OR
(
att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon'
)

关于php - 在 2 个表中搜索唯一条目,然后更改数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17556230/

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