Roy766 Posted June 15, 2011 Share Posted June 15, 2011 Hello all! I have a database with six different tables in it ("word", "idea", etc.). Each table has a timestamp column and what I want to do is have a page that lists all the rows entered within a certain time frame (a "New" page). In order to do this, though, I would have to query all six tables and then echo the rows created within a certain time frame. Is this possible? Thanks in advance! Also, if anyone has a suggestion on how to return all rows from a certain date onwards, that would be appreciated too. Quote Link to comment https://forums.phpfreaks.com/topic/239476-query-all-tables-in-a-database/ Share on other sites More sharing options...
Roy766 Posted June 16, 2011 Author Share Posted June 16, 2011 Figured out a work around; add each new post to the table "new" and limit the number of rows displayed on the "New" page. Doesn't work by date but the "most recent X rows" method actually makes more sense. Quote Link to comment https://forums.phpfreaks.com/topic/239476-query-all-tables-in-a-database/#findComment-1230262 Share on other sites More sharing options...
jcbones Posted June 16, 2011 Share Posted June 16, 2011 It will work by the date, if the date is stored in a date, datetime, or timestamp column. Having 6 queries in a page is a little bit of overhead, but hey, this page you are looking at was created with 16 queries (shown at the bottom). However, storing duplicate data is not something that I would recommend. If you are storing to two different tables, how do you handle edits, and/or deletions? Quote Link to comment https://forums.phpfreaks.com/topic/239476-query-all-tables-in-a-database/#findComment-1230266 Share on other sites More sharing options...
Roy766 Posted June 16, 2011 Author Share Posted June 16, 2011 No need for edits or deletions. If it becomes absolutely necessary I can manually edit the data, but it shouldn't be for the purpose of the site (only one person will be adding content, and he'll be copying the content from a document previously proofread and edited because he'll be printing it out as well as uploading it). In addition, there's no need to store very much content in the "new" table; any row after the most recent twenty can be automatically cleared. It's simple but efficient and works perfectly for the system I need. Quote Link to comment https://forums.phpfreaks.com/topic/239476-query-all-tables-in-a-database/#findComment-1230311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.