My query in PHP consist of two parts: creating temporary table and the main query.
How should I write this query in PHP?
//Creating temporary table part:
create temporary table mytable as(SELECT `Name`, `Date`, `Condition`
FROM info
ORDER BY `Date` DESC );
//The main query part:
select mytable.Name, mytable.Date, mytable.Condition FROM mytable
right join info on mytable.Name = info.Name
Group by mytable.Name;
Edited: My query contain 3 columns(Name, Date and Condition). I need the rows with max(Date), since I have some rows with the same Name, I should use Group.
The following query does not help:
SELECT `Name`, max(Date), `Condition`
FROM info
Group by Name
ORDER BY min(Date) DESC