如何根据键列表进行不同的mysql行更新

如何根据键列表进行不同的mysql行更新,mysql,sql,Mysql,Sql,我有一个每分钟下载一次的在线用户列表。。。此文件不包括当前脱机用户的ID 我需要更新mysql中在线和离线的用户。。。比如: update online=TRUE where userID in (list of online IDs) 然后做一个测试 update online=FALSE where userID NOT in (list of online IDs) 我很好奇是否有一个优雅的单sql解决方案。中的操作符返回一个布尔值,您可以这样说: update your_table

我有一个每分钟下载一次的在线用户列表。。。此文件不包括当前脱机用户的ID

我需要更新mysql中在线和离线的用户。。。比如:

update online=TRUE where userID in (list of online IDs)
然后做一个测试

update online=FALSE where userID NOT in (list of online IDs)

我很好奇是否有一个优雅的单sql解决方案。

中的
操作符返回一个布尔值,您可以这样说:

update your_table
set online = userID in (list of online IDs)
其中,当然,联机ID列表将是以逗号分隔的联机ID列表