現在資料5687條如下:
id name
1 ts
2 ab
3 at
4 ax
...
共14個欄位(其他未列舉),現將所有資料重新編號,但仍是id連續自增顯示,有多個結果,其一如下:
id name
1 ab
2 ax
3 ts
4 at
問,如何實作?一句話,就是將所有資料(采集別人的)順序打亂,打散重新存放。
uj5u.com熱心網友回復:
create table newtable like oldtableinsert into newtable (id,name....)
select (@a := @a+1) as xh,t.name,t.....
from (select name,.... from oldtable order by rand()) as t,(select @a := 0) as t1
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/249185.html
標籤:MySQL
