Reputation: 91
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");
Upvotes: 1
Views: 75
Reputation: 37233
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
??
Upvotes: 1
Reputation: 263703
since the data type is VARCHAR
you need to convert it to numeric, eg
ORDER BY CAST(s1.qid AS SIGNED) ASC
Upvotes: 0