Dan,
Thank you, that works! FYI, you can treat the field like a number,
including sorting, numeric functions, etc.
For example,
select * from table order by (text_field+0.0)
Steve Musumeche
CIO, Internet Retail Connection
[EMAIL PROTECTED]
Dan Nelson wrote:
In the last episode (Sep 28),
In the last episode (Sep 28), Steve Musumeche said:
> I think this method will work, however, when trying these queries, I get
> a SQL syntax error.
>
> mysql> select cast('34' AS decimal);
> ERROR 1064 (42000): You have an error in your SQL syntax; check the
> manual that corresponds to your My
I think this method will work, however, when trying these queries, I get
a SQL syntax error.
mysql> select cast('34' AS decimal);
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'decimal)'
Rajesh Mehrotra wrote:
Hi Steve,
Correction:
Use: "select * from table where field1 like '4%' or like '5%' or like
'6%' or field1 like '7%';"
This would not have the desired result as it would return things like
500 or 50 or 5,000,000 etc. You must use the cast as another reply
suggest
r 28, 2006 11:42 AM
To: '[EMAIL PROTECTED]'; mysql@lists.mysql.com
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
[EMAIL PROTECTED]
-Original Message-
You can use CAST or CONVERT to see the data as a numeric type.
If the table is very big and you're going to be querying it
intensely, you might want to create a separate column to store the
numeric data.
mysql> select cast('34' AS decimal);
+---+
| cast('34' AS decimal)
Hi Steve,
Try "select * from table where field1>=4% and field1<=7%" instead.
Sincerely,
Raj Mehrotra
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 27, 2006 11:24 PM
To: mysql@lists.mysql.com
Subject: making varchar fi