Forgot password?
 Register account
View 144|Reply 0

MySql交换表的两行

[Copy link]

3157

Threads

7925

Posts

610K

Credits

Credits
64218
QQ

Show all posts

hbghlyj Posted 2022-10-25 03:25 |Read mode
Last edited by hbghlyj 2022-10-26 19:06MySql取出tid为210和280的两行, 把它们的fid和subject交换
  1. update `forum_thread` a
  2. inner join `forum_thread` b on a.tid <> b.tid
  3.    set a.fid = b.fid,
  4.        a.subject = b.subject
  5. where a.tid in (210,280) and b.tid in (210,280)
Copy the Code
输出信息
2 rows affected. (Query took 0.0033 seconds.)
参考资料:
Mysql: Swap data for different rows

Mobile version|Discuz Math Forum

2025-6-6 14:45 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit