Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 MySQL 中加入一个?
例如,假设我有以下子查询:
select username, password from users
我想在更新中使用这些字段,如下所示:
update test_users set password = { result from subquery } where { result from subquery.user } = 100;
这是一个愚蠢的例子,但仅用于说明这一点。
基本上我的子查询返回两列,我需要在更新中使用它们。
您还可以将选定的字段存储在变量中:
SELECT login, password FROM sometable INTO @login, @password UPDATE othertable SET password = @password WHERE login = @login