Joran Den Houting
Joran Den Houting

Reputation: 3163

Sort by not working

$query = "SELECT * FROM websites WHERE url LIKE '%.nl/' OR '%.com/' OR '%.org/' ORDER BY views DESC";

Outputs:

enter image description here

Where is this coming from?..

Upvotes: 0

Views: 66

Answers (1)

John Conde
John Conde

Reputation: 219814

Views is apparently a string so it is being sorted as a string. You will need to cast that field to an INT before using it for sorting purposes (and you should change the data type to INT permanently).

Upvotes: 5

Related Questions