Here is the simplified version of my question. There are two tables one has machines and the second has their info about their state change with date reference(not actualy the date, but the shift index, that’s why I have to make another query to get the date itself).
I want to get the last state of each machine.
My query is:
SELECT * FROM machines
LEFT JOIN (SELECT * FROM statechange, dates WHERE....ORDER BY date DESC LIMIT 0,1) AS state
ON state.mid=machines.mid
But I get only one machine as a result of the query.
How can I do it without creating a view?
1 Answer