select max(t.d) from (select c1 as d from ttt union select c2 as d from ttt union select c3 as d from ttt)t
扩展用法:
update ttt set `max` = (select max(t.d) from (select c1 as d from ttt union select c2 as d from ttt union select c3 as d from ttt)t) where id=1
本文详细介绍了SQL查询中使用UNION结合子查询的方法,并展示了如何将查询结果应用于更新操作,以实现在数据库表中更新最大值。通过实例解析,帮助读者理解SQL在数据管理和更新中的强大能力。
1万+

被折叠的 条评论
为什么被折叠?



