Reputation: 925
I just want to ask how can the order by clause be performed first before the actual select statement.
I have query under PHP:
mysql_query("SELECT GROUP_CONCAT(sample_lang) AS locations
FROM postflight
WHERE rno='$cc'
ORDER BY sfno ASC") or die(mysql_error());
What the query does is to concat the values first before sorting it. What I want is to sort it by ascending first before concatting it. Any help will be appreciated. Thanks a lot!
Upvotes: 2
Views: 63
Reputation: 263693
You can use ORDER BY
inside GROUP_CONCAT()
function, try
SELECT GROUP_CONCAT(sample_lang ORDER BY sfno ASC)
FROM ...
WHERE ...
or if you want to add SEPARATOR
SELECT GROUP_CONCAT(sample_lang ORDER BY sfno ASC SEPARATOR '-')
FROM ...
WHERE ...
Upvotes: 4