Hello all,
I have a database which has 10 tables. Each table has an id, a title and a date.
Now i'm having difficulty finding the best way to extract the latest date from each unique table, while also doing a count(*) attribute to show how many rows I have in that table.
Here is an example -
I used the code tag to make it easier to see,
Table A has 3 values.
+----+----------------+------------+
| ID | Title | date |
+----|----------------+------------+
| 1 | First Row | 2011-06-15 |
| 2 | Second Row | 2011-06-14 |
| 3 | Third Row | 2011-06-13 |
+----+----------------+------------+
Table B has 2 values.
+----+----------------+------------+
| ID | Title | date |
+----|----------------+------------+
| 20 | First Row | 2011-05-15 |
| 30 | Second Row | 2011-03-14 |
+----+----------------+------------+
Is it even possible for me to attain this? -
Latest date of the unique table is shown, only has 1 row per table.
+----+----------------+------------+----------+
| ID | Title | date | count(*) |
+----|----------------+------------+----------+
| 1 | First Row | 2011-06-15 | 3 |
| 20 | First Row | 2011-05-15 | 2 |
+----+----------------+------------+----------+
If its possible, what is the best method of coding the sql query? A nested query?
** I am using php to connect to the db as well as format the output.
Thanks