mysql multiple column sorting order -
i have 1 table 6 columns tinyint 1 digit. need query return data sorted (ordered) desc in each column.
example:
col1 col2 col3 1 2 5 1 7 3 2 3 7
expected result:
2 7 7 1 3 5 1 2 3
i tried order col1, col2 desc affects first column (maybe because it's same table?) thx, danny
i assuming getting data same table, what's causing problem, because, when saying orderby, db engine assumes row data consistent , should not split, orders first selector, col1 in case. solution is, acquire each column it's own, ordered, in separate query, , then, you'll result. so, end up, in simple way of doing it, 3 queries:
select col1 table orderby col1 desc;
select col2 table orderby col2 desc;
and on
Comments
Post a Comment