rmpotter Posted October 22, 2009 Share Posted October 22, 2009 Currently I am attempting to pull some data using:$sql="select * from inspect_erp where inspection_id = ".$myid." ORDER BY erp_type";the fields in the table areerp_id, inspection_id, erp_type, gpslocationBasically, I am looking to alter this to have the SQL order by the most commonly occurring erp_type to the least occuring. Can anyone help me out? Link to comment Share on other sites More sharing options...
Kameloh Posted October 22, 2009 Share Posted October 22, 2009 $sql = "SELECT * FROM inspect_erp WHERE inspection_id='$myid' ORDER BY erp_type DESC"; you can probably add ASC or DESC right after erp_type - unless you wanted something else more specific? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 22, 2009 Share Posted October 22, 2009 I don't think you're able to do that with one query, you'll have to do one query to get the erp_types and the number of times they appear, and one or more other queries to get the items for each type. Link to comment Share on other sites More sharing options...
rmpotter Posted October 22, 2009 Author Share Posted October 22, 2009 I don't think you're able to do that with one query, you'll have to do one query to get the erp_types and the number of times they appear, and one or more other queries to get the items for each type.Unfortunately, that's what I figured. I will fool around with it an post a solution for anyone interested. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.