gpt4 book ai didi

使用组合 xy 或 yx 的 MySQL 更新查询

转载 作者:行者123 更新时间:2023-11-28 23:39:46 24 4
gpt4 key购买 nike

我知道这个问题有点模棱两可。我希望我能在这里澄清这个问题。

我有一张 table ,Table Name: user_group_relation

|--------------------------------------|
| userId | userId_1 | groupId | amount |
|--------------------------------------|
| 3 | 5 | 1 | 0.00 |
|--------------------------------------|

我想对表进行更新,因为我有两列 userId 和 userId_1,它们具有两个不同用户的 userId。

我有一个关系 (3,5) 有什么方法可以在表中查找此组合,其中关系 (userId_1, userId) 可以存储为 (3,5) 或 (5,3) )

最佳答案

你是说

SELECT * FROM user_group_relation WHERE (userId_1 = 3 AND userId = 5) 
OR (userId_1 = 5 AND userId = 3);

UPDATE user_group_relation set userId_1 = <value>, userId = <value> 
WHERE (userId_1 = 3 AND userId = 5) OR (userId_1 = 5 AND userId = 3);

?

关于使用组合 xy 或 yx 的 MySQL 更新查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34730787/

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