Use: "select * from table where field1 like '4%' or like '5%' or like
'6%' or field1 like '7%';"
From: Rajesh Mehrotra
Sent: Thursday, September 28, 2006 11:42 AM
To: 'steve@stripped'; mysql@stripped
Subject: RE: making varchar field to act like numeric field
Try "select * from table where field1>=4% and field1<=7%" instead.
Sent: Wednesday, September 27, 2006 11:24 PM
Subject: making varchar field to act like numeric field
I am looking for any suggestions to this problem. I have a table with a
varchar field. This field can hold textual or numeric data, but it is
stored in a varchar field so the database sees it all as text.
I need to be able to search and sort this field as if it were numeric.
For example, here is some sample data
I need to be able query the table to get the rows within a certain
range, for example, between 4 and 7:
select * from table where field1>=4 and field1<=7
This doesn't work because the column is not a numeric data type. Is
there anyway to dynamically cast the data to a numeric format so I can
use MySQL's numeric sorting?
I can't change the field's data type because it also needs to be able to
hold textual data. Thank you for your help.
CIO, Internet Retail Connection
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=1