<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    438 MySQL Technical Reference for Version 4.0.3 To cast a string to a numeric value, you don't normally have to do anything; just use the string value as it would be a number: mysql> SELECT 1+'1'; -> 2 MySQL supports arithmetic with both signed and unsigned 64-bit values.  If you are using an numerical operations (like +) and one of the operands are unsigned integer, then the result  will  be  unsigned.   You  can  override  this  by  using  the  SIGNED  and  UNSIGNED  cast operators, which will cast the operation to a signed or unsigned 64-bit integer, respectively. mysql> SELECT CAST(1-2 AS UNSIGNED) -> 18446744073709551615 mysql> SELECT CAST(CAST(1-2 AS UNSIGNED) AS SIGNED); -> -1 Note that if either operation is a oating-point value (In this context DECIMAL() is regarded as a oating-point value) the result will be a oating-point value and is not a ected by the above rule. mysql> SELECT CAST(1 AS UNSIGNED) -2.0 -> -1.0 If you are using a string in an arithmetic operation,  this is converted to a oating-point number. The CAST() and CONVERT() functions were added in MySQL 4.0.2. The handing of unsigned values was changed in MySQL 4.0 to be able to support BIGINT values properly.  If you have some code that you want to run in both MySQL 4.0 and 3.23 (in which case you probably can't use the CAST function), you can use the following trick to get a signed result when subtracting two unsigned integer columns: SELECT (unsigned_column_1+0.0)-(unsigned_column_2+0.0); The idea is that the columns are converted to oating-point before doing the subtraction. If you get a problem with UNSIGNED columns in your old MySQL application when porting to MySQL 4.0, you can use the --sql-mode=NO_UNSIGNED_SUBTRACTION option when starting mysqld.  Note however that as long as you use this, you will not be able to make ecient use of the UNSIGNED BIGINT column type. 6.3.6  Other Functions 6.3.6.1  Bit Functions MySQL uses BIGINT (64-bit) arithmetic for bit operations, so these operators have a max- imum range of 64 bits. | Bitwise OR mysql> SELECT 29 | 15; -> 31 The result is an unsigned 64-bit integer.
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN REGISTRATION
    MANAGE YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    SITE MAP
    Home
    Hosting Plans | Domain Registration | About Us | Contact Us | Site Map
    Terms of Use | Privacy Policy | Guarantees
    Merchant Accounts

    SpiritHost - web hosting for spiritual and education sites
    SpiritHit.com - Religious and Spiritual Portal
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide