vendredi 8 mai 2015

Database Random to many to many

I am a newbie. I have a table1 that stores User_id 's and another table2 that stores data_id's Data_id's will be selected random from table2 and all the user_id's should have all the random data_id.

                          table1                table2    
                          user1                 data1
                          user2                 data2
                          user3                 data3
                          user4                 data4
                          user5                 data5

I want to get 3 random data from table2 and write these data's with user_id's to table3 it should look like below

                                  table3
                              user1   data2                                                     
                              user1   data3
                              user1   data4  
                              user2   data2                                                     
                              user2   data3
                              user2   data4     
                              user3   data2                                                     
                              user3   data3
                              user3   data4  
                              user4   data2                                                     
                              user4   data3
                              user4   data4  
                              user5   data2                                                     
                              user5   data3
                              user5   data4                   




Aucun commentaire:

Enregistrer un commentaire