Re: maybe a bug

2002-06-14 Thread Roger Baklund

* [EMAIL PROTECTED]
> In order to remove the first character '0' of the field 'number',
> I want to use the following sql query to select the field from my 
> database.
> 
> select right(number, 
> if(locate('0',length(number))=1,length(number)-1,length(number))) 
> as 'no_zero' from mydatabase order by id desc LIMIT 0, 30 

locate('0',length(number))=1 will only be true when number="".

Mysql can do string to number conversions automatically:

mysql> select '0123'+0;
+--+
| '0123'+0 |
+--+
|  123 |
+--+
1 row in set (0.00 sec)

-- 
Roger
sql

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: maybe a bug

2002-06-13 Thread Galen Wright-Watson

On Fri, 14 Jun 2002, [GB2312] ³Â׿ wrote:

> mysqlmysql 3.23.41
> phpMyAdmin 2.2.3
> os :Linux server 2.4.9-31
> 
> In order to remove the first character '0' of the field 'number',
> I want to use the following sql query to select the field from my database.
> 
> select right(number, 
>if(locate('0',length(number))=1,length(number)-1,length(number))) as 'no_zero' from 
>mydatabase order by id desc LIMIT 0, 30 
> 
> when i use the order sub query 'order by id asc',this sql query will take effect , 
>the first character'0' will be removed.
> when i use the order sub query 'order by id desc',this sql query will take no effect 
>, the first character '0' will not be removed.
> 
> I think it's a bug.

What happens if the LIMIT clause is removed?

> 
> sorry about my poor English,waitting for your letter in reply.
> 

Your English is fine; much better than my French or Russian.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail 
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php