CodingJoe Posted March 7, 2007 Share Posted March 7, 2007 I have 2 tables, CLOTHES id sort_id owner_id LOG clothes_id datetime action - enum(new,washed,removed) I want the last washed of each sort, so the result should be clothes.id clothes.sort_id log.datetime I can't think of a way to do this in 1 query, does anybody had an idea? Link to comment https://forums.phpfreaks.com/topic/41546-howto-combine-3-queries-in-1/ Share on other sites More sharing options...
fenway Posted March 7, 2007 Share Posted March 7, 2007 WHere's the third query? Link to comment https://forums.phpfreaks.com/topic/41546-howto-combine-3-queries-in-1/#findComment-201410 Share on other sites More sharing options...
artacus Posted March 7, 2007 Share Posted March 7, 2007 I don't understand how sort plays into this. You didn't provide enough info. But based on what you gave SELECT c.id, c.sort_id, MAX(log.datetime) FROM clothes AS c JOIN log ON c.id = log.clothes_id GROUP BY c.sort_id Link to comment https://forums.phpfreaks.com/topic/41546-howto-combine-3-queries-in-1/#findComment-201423 Share on other sites More sharing options...
fenway Posted March 7, 2007 Share Posted March 7, 2007 I'm glad you didn't see it ether. Link to comment https://forums.phpfreaks.com/topic/41546-howto-combine-3-queries-in-1/#findComment-201837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.