求助jqa中的sql,联表更新语句怎么写?
t1表中是一些用户个性信息需要更新t1表中的用户个性信息,根据t1表中的userid字段来跟新,userid的值是user这个表中的住建,现在入参为用户账号。需要通过用户账号查到user表中的id,再根据这个id去更新对应的用户信息我目前写的是update config t1 set t1.color = :color, t1.name = :name where t1.userId in (select t1.userId from (select userId from user t2 where t2.account = :account))求助大神指教!!!!
回复
1个回答

test
2024-07-03
子查询里你要选user表的id,不是config表的userId
UPDATE config t1
SET t1.color = :color, t1.name = :name
WHERE t1.userId IN (
SELECT t2.id FROM user t2 WHERE t2.account = :account
)
回复

适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容