Hi everybody!
Here's my problem: I have 3 MySql tables representing: photos a user post, videos a user post, comments a user post and I need to view the 10 (20, 30, 40...) most recent activities by the user. For example in photos table may be composed by:
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
the videos 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
the comments 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 the 3 tables have different number of attributes, so how can I do the union? and while fetching the query result how can i understand to wich table it belongs to?
So in the user profile page I'd like to show his recent activities of course ordered by DATE DESC this way:
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 anyone help me please?