Forgot password?
 Create new account
View 98|Reply 0

MySql交换表的两行

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-10-25 03:25:34 |Read mode
Last edited by hbghlyj at 2022-10-26 19:06:00MySql取出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|Leisure Math Forum

2025-4-20 22:11 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list