Retrieving the 25 most recently added entries from all tables in a MySQL databas


Posted on 16th Feb 2014 07:03 pm by admin

Hello,

The code below works great. It creates a table that shows the 25 most recently added tables to a MySQL database called "sitefeather."

Did you know?Explore Trending and Topic pages for more stories like this.
Each one of these tables has the following structure:

Code: id INT(11) NOT NULL auto_increment, site VARCHAR(1000) NOT NULL, action1 BIGINT(9) NOT NULL, action2 BIGINT(9) NOT NULL, createddatetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(id), UNIQUE (site)
I would like to echo a list of "site" and "CURRENT_TIMESTAMP" for the 25 most recently added rows, regardless of which table they are in. This may be tricky since the number of tables is variable. Someone advised me that I would have to use a query involving INFORMATION_SCHEMA.TABLES. How can I do this?

Thanks in advance,

John

Code: echo "<table class="samples">";
$index = mysql_query("select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='sitefeather' order by CREATE_TIME desc limit 25");
while ($row = mysql_fetch_array($index))
{
echo '<tr><td><a href="sitesearch.php?find='.urlencode($row['TABLE_NAME']).'&searching=yes&search=search">'.$row['TABLE_NAME'].'</a></td></tr>';

}
echo "</table>";
No comments posted yet

Your Answer:

Login to answer
309 Like 19 Dislike
Previous forums Next forums
Other forums

Help with syntax
Hi all!

The $bridge variable is not getting passed while it is contained in the line below:

Adding Different Numbers From MySQL
Basically I have a mysql database with a couple prices as the following:

9.99
9.99
9.99

Sales orders ans reservations not taken into account on MPS / MRP
Hello,

I am implementing the MPS / MRP and I have the following problem:

I ha

Taking an HTML form and a PHP program and making it into one working file.
Hello,

So I would like to display everything INSIDE a specific directory. In other words, I

Move array index to end
Hey guys,
Quick question:

I have an array that looks like this:
Code: [Select]$var =

modifying query string with no page refresh
Hi everybody,
I've tried to get info about my problem all over the internet but i didn't find out

file_put_contents and createimagefromjpeg
All,
I do somethings and then I have the following code:
file_put_contents('./test/'.$filename

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

Export hangs
Hi all, please help

I have a Oracle 10.2.0.3.0 database. When I want to query the dba_segmen

PHP/PKI
I am trying to set up a web application that uses pki. does anyone have a good tutorial to set this

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash