I have a website where users can comment on photos. I have a table of comments in this format:
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(12) | NO | | NULL | |
| id | varchar(32) | NO | MUL | NULL | |
| whenadd | int(20) | NO | | NULL | |
| text | text | NO | | NULL | |
+----------+-------------+------+-----+---------+-------+
And a table of photos in this format: (JUST TO CLARIFY, ID refers to ID in the photo table, this is abbreviated)
+----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+-------+
| id | varchar(32) | NO | PRI | NULL | |
| type | varchar(5) | NO | | NULL | |
+----------+------------------+------+-----+---------+-------+
So basically, I'm trying to return the photos that have been commented, in the date in which they were commented, ordered by the most recent comment on each photo. I have tried using INNER JOIN to do it, but it never seems to work right. Any ideas?