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