List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 10 2001 4:12pm
Subject:Re: Simple select problem.
View as plain text  
At 5:46 PM +0300 9/9/01, Eyal Rif wrote:
>Hi,
>
>I have a table with the format of :
>
>char(20),int(7),char(32)
>
>the "Date char(20)" contents in actually a number(seconds since 1970) -
>
>I want to use a "select" query that will give the max value according to
>number value of that column.
>
>select @last:=MAX(Date) from stat1;
>
>What I need to know is how to convert a string to a number on a select
>statement.

Add zero to it.  The first comparison below is performed in lexical
order, the second in numeric order:

mysql> SELECT '9' < '13';
+------------+
| '9' < '13' |
+------------+
|          0 |
+------------+
mysql> SELECT '9'+0 < '13'+0;
+----------------+
| '9'+0 < '13'+0 |
+----------------+
|              1 |
+----------------+


>
>Any help/reference will be appreciated
>
>Thanks,


-- 
Paul DuBois, paul@stripped
Thread
Simple select problem.Eyal Rif9 Sep
  • Re: Simple select problem.Gerald Clark10 Sep
  • Re: Simple select problem.Paul DuBois10 Sep