Home
Sign Up
Sign In
V2EX
›
问与答
求打乱排序的 sql 语句
baiduyixia
·
May 30, 2023
· 1757 views
This topic created in 1146 days ago, the information mentioned may be changed or developed.
mysql ,a 表的字段 b 里面是一组数字,数字间用符号|隔离,比如 1 | 3 | 4 | 9 ,请问 sql 如何将字段 b 里面的 数字顺序随机打乱替换上去,谢谢
SQL
打乱
MySQL
数字
4 replies
•
2023-05-31 09:14:34 +08:00
1
urnoob
May 30, 2023 via Android
写个存储过程
游标遍历每一行
对 b 列值做分割
随机拼
update
最后记得
commit
2
japeth
May 30, 2023
取出来 程序处理更方便吧
3
NauxLiu
May 30, 2023
理论上可以将 b 字段 split 开然后列转行,再 order by rand , 最后在 group concat 起来行转列。但是性能肯定是灾难性的。
4
makelove
May 31, 2023
这种问题一般是 chatgpt 的拿手好戏,我碰到这类边界很确定的都是直接扔 gpt 回来几乎不用改
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
5548 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 30576480 · 65ms ·
UTC 01:36
·
PVG 09:36
·
LAX 18:36
·
JFK 21:36
♥ Do have faith in what you're doing.
❯