Home > database >  For a single SQL update statement
For a single SQL update statement

Time:01-04

member table fields id, avatar, avatar2 avatar3, avatar4

my moment table fields id, memberid, PIC


Moment in the table memberid corresponding member id in the table


Hope that through the SQL statement to achieve the following functions

Find my moment memberid field specifies the data in the table, from the results, randomly selected 3 PIC field data is inserted into the member table corresponding to the id of avatar2, avatar3, avatar4 these three fields;

For example:



SELECT the PIC FROM ` moment ` where memberid=1458 ORDER BY RAND () LIMIT 3

The query results in article 3 of the data update in the table to the member avatar2, avatar3, avatar4 three fields, condition id=my moment. Memberid
  • Related