我有一個關於從多個表建立一個mysql查詢的問題。 這些表如下:有人可以幫我用mysql查詢嗎?
comments: comment_id, entry_id, user_id, comment, time..
users: user_id, user_name..
profile_photos: photo_id, user_id, photo_name
我想從意見表中的所有comments
特定entry_id
,併爲所有這些用戶(誰寫的評論),我想要得到的photo_id(從profile_photos表,和用戶表中的user_name)。
例如2個用戶user_id「1」和「2」對「entry_id」「1」發表了評論。我想從這兩個用戶的評論表中獲取評論數據,以及他們的user_name和photo_id。
如果有人能幫助我查詢,我會非常感激。
第一個停靠港:http://en.wikipedia.org/wiki/Join_(SQL) – YXD 2011-04-25 20:41:59