member表 欄位 id、avatar、avatar2、avatar3、avatar4
moment 表 欄位 id、memberid、pic
對應關系
moment 表中的 memberid 對應 member表中的id
希望通過sql陳述句 實作如下功能
查找moment表中 memberid 欄位指定資料,從結果中,隨機抽取3條 PIC欄位 資料 插入到member表 對應id 中 avatar2 、avatar3、avatar4這三個欄位;
舉例說明:

SELECT pic FROM `moment` where memberid=1458 ORDER BY RAND() LIMIT 3
把查詢出來的3條資料結果 update 到 member表中 avatar2、avatar3、avatar4 三個欄位中,條件 id=moment.memberid
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/244036.html
標籤:MySQL
