I have two tables:
T1
t1_id, location, description
T2
t2_id, t1_id, date
the id fields are tinyint auto increment pk. location is type VARCHAR, description is type TEXT, and date is type DATE.
I am trying to get each location, description and the date ordered by the date in desc order. I only need the most recent date per location. (Need to know when the location was last used but I want to keep a log of all uses just in case.)
I've seemed to have gotten it to work somewhat with the query:
$q = "select t1.location, t1.description, t2.date from t1, t2 where t2.t1_id = t1.t1_id order by DATE_FORMAT(t2.date, '%m/%d/%y') desc";
I'm not 100% how's it giving me data. I just show 2012/01/19, 2011/08/10, 2012/01/20 when it should be 2011, 2012/01/19, 2012/01/20. I'm thinking because the 2012/01/19 has multiple entries in t2 it might be causing some issue.