Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Mysql - Converting varchar field to tinyint


jaruba - 5:37 pm on May 15, 2011 (gmt 0)


When I first created the database, I made a varchar(4) type field to store ratings in, the ratings can be in a radius of 0.0 to 10.0 (other examples: 8.45, 9.12, 5.20) (this field is called "rating")

The problem is that now I want to create a top, and need to ORDER BY rating DESC, the issue here is that the rows that have 10.0 are obviously not ordered first.

For a solution, at the moment I use 2 queries to get the necessary results. Now I imagine that converting this field from varchar(4) to tinyint would solve my problem and I should get the results with only 1 query, but I would prefer knowing if this can be done and that it wouldn't create any website bugs.

Thank you in advance for any help on my issue.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4312723.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com