spec36 Posted September 12, 2012 Share Posted September 12, 2012 I am running the following query in my php code. $query="SELECT *, MAX(percent_complete) FROM $dbtable GROUP BY percent_complete DESC LIMIT 4 OFFSET 8"; In the database percent_complete has the following rows. 1. 100 2. 80 3. 50 4. 30 5. 30 6. 30 The query above lists the percent complete values in a table, but for some reason it is not including the 3x 30 (#4,5,6 above) it only shows the first one. I want to be able to show all 3x30's in the table. Examples: I want it to show like this in the table: |100|80|50|30|30|30 But for some reason it is like this: |100|80|50|30 Anyone have any idea as to why the other two 30% records on not showing in the results? Note: Please don't get confused with the LIMIT 4 OFFSET 8 in the query and the example I used. The database has enough records after the 8th record to show 4 in the row. This row should technically be showing |30|30|30|30 on my actual test site. But it just shows |30|. Help would be greatly appreciated. Thanks, Spec36 Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 12, 2012 Share Posted September 12, 2012 That's what group by does. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 12, 2012 Share Posted September 12, 2012 MAX(xyz) coupled with GROUP BY xyz is one of the first signs of insanity. Quote Link to comment Share on other sites More sharing options...
spec36 Posted September 12, 2012 Author Share Posted September 12, 2012 Do you know what I can use instead of group by so the duplicate records will be shown? Quote Link to comment Share on other sites More sharing options...
spec36 Posted September 12, 2012 Author Share Posted September 12, 2012 Ok I resolved this by changing my code to the below: $query="SELECT * FROM $dbtable_auctions ORDER BY percent_complete DESC LIMIT 4"; Quote Link to comment 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.