wayne Posted December 24, 2007 Share Posted December 24, 2007 Hi Sorry for simplistic question but new to mysql and having problems figuring how to write an update statement where my select has a group by, wonder if anyone can help as need urgently. I have table called FLATRESULTS column i need to populate with a 'Y' is called FAV Now i need to populate this column for each row with a 'Y' where the racenumber for the row and decodds = min_odds from the query below select racenumber, min(decodds) as min_odds from flatresults group by racenumber hope that makes sense, help appreciated. Wayne Quote Link to comment https://forums.phpfreaks.com/topic/83028-solved-update-statement/ Share on other sites More sharing options...
Barand Posted December 24, 2007 Share Posted December 24, 2007 try UPDATE flatresults a INNER JOIN (SELECT racenumber, MIN(decodds) as minodds FROM flatresults GROUP BY racenumber) as x ON a.racenumber = x.racenumber AND a.decodds = x.minodds SET a.fav='Y' Quote Link to comment https://forums.phpfreaks.com/topic/83028-solved-update-statement/#findComment-422648 Share on other sites More sharing options...
wayne Posted December 26, 2007 Author Share Posted December 26, 2007 Thank You very much Barand, done the trick, much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/83028-solved-update-statement/#findComment-423416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.