CSmith1128 Posted April 14, 2009 Share Posted April 14, 2009 Hey.. I need some help.. I have a database with a few tables in it. 1 table is for images, another table is for comments, another table is for friends, and another table is for announcements. The friends table has a unique_id, friend_id and user_id. Every other table has a unique_id, user_id, add_date, and add_time. I need to go through the friends list table, and for every entry in the table that contains a certain user_id, I need to get the most recent entries from the other tables that contain the friend_id associated with the user_id in the friends table. So, for all my friends, I want to display the most recently uploaded images, comments, and announcements. I don't want to show the most recent from EVERY user, just the top 50 recent entries. So the top 50 out of everyone. I want a total of the 50 most recent entries so I can display them on a users home page. I have no idea how I would get started with this. I'm using php, and I was thinking about putting them all in an array and then sort them all by the date and time, but I dont think it would be very efficient. Can anyone help me get started or show me where to look for some ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/153952-solved-need-some-help-retrieving-data-from-tables/ Share on other sites More sharing options...
fenway Posted April 14, 2009 Share Posted April 14, 2009 So, for all my friends, I want to display the most recently uploaded images, comments, and announcements. I don't want to show the most recent from EVERY user, just the top 50 recent entries. So the top 50 out of everyone. And why can't you use an ORDER BY / LIMIT? Link to comment https://forums.phpfreaks.com/topic/153952-solved-need-some-help-retrieving-data-from-tables/#findComment-810125 Share on other sites More sharing options...
CSmith1128 Posted April 14, 2009 Author Share Posted April 14, 2009 Can I 'order by' using the date and time from every table? I know I can select data from multiple tables, but can can i order them all? Link to comment https://forums.phpfreaks.com/topic/153952-solved-need-some-help-retrieving-data-from-tables/#findComment-810176 Share on other sites More sharing options...
CSmith1128 Posted April 14, 2009 Author Share Posted April 14, 2009 do you think a union would be efficient? Link to comment https://forums.phpfreaks.com/topic/153952-solved-need-some-help-retrieving-data-from-tables/#findComment-810184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.