Here is my problem: I have 3 MySql tables representing: photos, user posts, user videos, user comments, and I need to view the last 10 (20, 30, 40 ...) users. For example, in the table of photographs can be compiled:
user_id | photo_id | photo_path | photo_name | date_added
5 | 18 | / photos | pht_18.png | 2009-02-12
5 | 21 | / photos | pht_21.png | 2009-02-15
5 | 29 | / photos | pht_29.png | 2009-03-30
video table
user_id | video_id | video_url | date_added
5 | 36 | youtube.com / ... | 2009-01-09
5 | 48 | youtube.com / ... | 2009-02-18
5 | 90 | youtube.com / ... | 2009-03-19
comment table
user_id | comment_id | comment | date_added
5 | 6 | hi! | 2009-02-11
5 | 11 | great photo | 2009-02-13
5 | 19 | nice shot! | 2009-03-28
As you can see, 3 tables have a different number of attributes, so how can I do a join? and when retrieving the result of the query, how can I understand which table it belongs to?
So, on the user profile page, I would like to show his recent actions, which, of course, are ordered by DATE DESC as follows:
2009-09-01: user posted a video
2009-11-02: user posted a comment
2009-12-02: user posted a photo
2009-13-02: user posted a comment
2009-15-02: user posted a photo
2009-18-02: user posted a video
2009-19-03: user posted a video
2009-28-03: user posted a comment
2009-30-03: user posted a photo
Can anybody help me?
php mysql
Aldob
source share