Sorting 4 Different Tables By Date
I'm working with a site where there are 4+ different types of items that can be on the front page (like photos, blog posts, reviews, etc) and these are stored in 4 different database tables that really can't be combined into one table easily.
I want to sort these on the front page by date desc so the latest 5 are displayed. Currently i'm using a multiple dimension array to do this but I figure there's got to be a much easier way possibly through a MySQL view or join or something. All 4 columns have a DATE field to sort by...any ideas? All I would need to return is the type and the primary key and I'd be fine.
Any help would be appreciated.
is it too late to make a 5th table, named "postings" that has structure something like
posting_id int primary key
posted_item_id int (fake foreign key to one of those 4 tables)
posted_item_table varchar(64) (the name of the table that id is in)
if not, then surely all 4 of these tables have a posting date. you could just use union to bring them together, and then sort the union.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread