mysql - How to randomize the sql result set (column)? -
string q="insert chooserandom (qid,question,option1,option2,option3,option4,answer,isimage,imagequestion) select qid,question,option1,option2,option3,option4,answer,isimage,imagequestion model order rand()";
i using above query randomize sql result set , insert randomized data's new table. works query randomize rows in table. need randomize rows column , insert new table.
how can can 1 help me prepare this
thanks in advance
compare image 1 , image 2 options randomized rows randomized.
how can accomplish this
actually problem can randomize database table info using rand() function in mysql. need shuffle column's so.
i solve issue using array list in java add together column values list , shuffle list list item 1 1 code used given bellow .
list<string> lst = new arraylist<string>(); op1=rs.getstring("option1"); op2=rs.getstring("option2"); op3=rs.getstring("option3"); op4=rs.getstring("option4"); lst.add(op1); lst.add(op2); lst.add(op3); lst.add(op4); collections.shuffle(lst); op1=lst.get(0); op2=lst.get(1); op3=lst.get(2); op4=lst.get(3);
than used values ever want.
mysql random
No comments:
Post a Comment