Forgot password
 Register account
View 144|Reply 0

MySql交换表的两行

[Copy link]

3222

Threads

7841

Posts

52

Reputation

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

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-22 03:39 GMT+8

Powered by Discuz!

Processed in 0.025987 seconds, 29 queries