In MySQL, the use rules of the cast function

Source: Internet
Author: User

The CAST function syntax rule is: cast (the type of the field name as conversion), where the type can be:

char[(N)] character type
Date type
DateTime Date and Time type
DECIMAL Float Type
Signed int
Time Type

Example 1:

table Table1date:  - -  One - Geneva : +-Selectcast as as from  table1;

Results:
date:20151103153126

 select  cast  (date as  char ) as  date from   table1; The results are as follows: Date:  2015  - 11  - 03  15 : 31 :  
Example 2: Select cast  as datetime  as  from   table1; The result is as follows: Date:---: £ º

  instance 3:  select  cast  (Date as  date) as  date from   table1; The result is as follows: Date:  2015  - 11  - 03  
Example 4: Select cast  as  as  from   table1; the results are as follows: Date:+ :

This date corresponds to the time

Example 5: Table Table2num:  - Select cast  as decimal (2  as from table2 results as follows: num:20.00

In MySQL, the use rules of the cast function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.