如何在MySQL的左外连接中有序显示类别

How could I display this query, ordered by qid?

  $newcount=$db->get_results("
        SELECT  s2.qcategory, 
                s1.id, 
                count(s1.na) as na_count 
        FROM    (
                    select  distinct `qcategory` 
                    from    store 
                    where   survey_name='$userID' and 
                            dateone='$dateVal' and 
                            branch='$branch'
                ) s2 
                left join store s1 
                    on s1.`qcategory` = s2.`qcategory` and 
                        s1.`na` = '1' 
        group by 1 
        order by s1.qid");

since the data type is VARCHAR you need to convert it to numeric, eg

ORDER BY CAST(s1.qid AS SIGNED) ASC

u maybe want to order ASC or DESC

try this

     ORDER BY s1.qid  ASC   

or

   ORDER BY s1.qid  DESC

and why you make GROUP BY 1 ??