我有這個數據庫:MYSQL - 加入三個表
Image : id,user_id,[..],created_at
Visit : id,image_id,created_at
user : id,[..]
,我有這個疑問讓高層上傳用戶,
$current_month = date('Y-m-d', strtotime("first day of this month")) . ' 23:59:59';
$users = DB::query("SELECT * ,
COUNT(p.id) as numPics
FROM
images p
INNER JOIN
users u
ON
p.user_id = u.id
WHERE
p.created_at >= \"$current_month\"
GROUP BY p.user_id
ORDER BY numPics DESC LIMIT 10");
我有什麼是joing訪問表,所以我可以在當前月份獲得每幅圖像的總體勝率。
複製http://stackoverflow.com/questions/16406703/joing-three-tables-on-mysql – bksi 2013-05-06 20:57:00