Categories > TinyButStrong general >

sort on many fields

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: donatello
Date: 2007-02-20
Time: 15:12

sort on many fields

Hi, i am trying to sort data by field with tbs, using sql query.
This works:
SELECT * FROM myTable ORDER BY item1 DESC

But this doesn't:
SELECT * FROM myTable ORDER BY item1 DESC, item2 ASC, item3 DESC

In the second query, the data is sorted on item1,but not items 2 and 3.
Is there a mistake in the query or tdbs doesn't support it?
My tbs version is 2.05.1

Cheers.
By: Bob
Date: 2007-02-20
Time: 15:27

Re: sort on many fields

Hi,

This has nothing to do with TBS.
TBS just gives the SQL statement to MYSQL as is (except for sub-blocks).

Try your query in PhpMyAdmin to see the result. TBS should display the same.
By: TomH
Date: 2007-02-20
Time: 15:33

Re: sort on many fields

Try a simple (non-TBS) php script to see what's going on.

If you're using MySQL try the "explain" query
EXPLAIN SELECT * FROM myTable ORDER BY item1 DESC, item2 ASC, item3 DESC
By: donatello
Date: 2007-02-20
Time: 15:48

Re: sort on many fields

you were right, same result in phpmyadmin...i don't understand, cause there's no error! the query is executed, but not correctly.
By: sheepy
Date: 2007-02-22
Time: 12:14

Re: sort on many fields

Make sure MySQL is up to date.  Check that the collation is correct (very important).  Try a query without order by to verify that the data is correct.  If problem persists, consult Google.

http://www.searchmash.com/search/mysql+sort+incorrectly