Hi Steve,
Correction:
Use: "select * from table where field1 like '4%' or like '5%' or like
'6%' or field1 like '7%';"
Sincerely,
Raj Mehrotra
raj@stripped
-----Original Message-----
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
Hi Steve,
Try "select * from table where field1>=4% and field1<=7%" instead.
Sincerely,
Raj Mehrotra
raj@stripped
-----Original Message-----
From: steve@stripped
[mailto:steve@stripped]
Sent: Wednesday, September 27, 2006 11:24 PM
To: mysql@stripped
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
2.5
4
2
6
7
6.2
3.4
6
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.
--
Steve Musumeche
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