0
0
MySQLquery~10 mins

Type casting and conversion in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to convert the string '123' to an integer using CAST.

MySQL
SELECT CAST('123' AS [1]);
Drag options to blanks, or click blank then click option'
ASIGNED
BDECIMAL
CDATE
DCHAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using CHAR instead of SIGNED causes no numeric conversion.
Using DATE or DECIMAL changes the type incorrectly.
2fill in blank
medium

Complete the code to convert the integer 2023 to a string using CAST.

MySQL
SELECT CAST(2023 AS [1]);
Drag options to blanks, or click blank then click option'
ASIGNED
BDECIMAL
CDATE
DCHAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using SIGNED keeps it as a number.
Using DATE or DECIMAL changes the type incorrectly.
3fill in blank
hard

Fix the error in the code to convert the string '2023-06-01' to a DATE type.

MySQL
SELECT CAST('2023-06-01' AS [1]);
Drag options to blanks, or click blank then click option'
ASIGNED
BCHAR
CDATE
DDECIMAL
Attempts:
3 left
💡 Hint
Common Mistakes
Using SIGNED or DECIMAL causes conversion errors.
Using CHAR keeps it as a string.
4fill in blank
hard

Fill both blanks to convert the string '123.45' to a decimal number with 5 digits and 2 decimals.

MySQL
SELECT CAST('123.45' AS [1]([2], 2));
Drag options to blanks, or click blank then click option'
ADECIMAL
BSIGNED
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using SIGNED instead of DECIMAL causes wrong type.
Using 10 instead of 5 changes precision.
5fill in blank
hard

Fill all three blanks to convert the string '2023-06-01 12:30:00' to a DATETIME type and alias it as 'converted'.

MySQL
SELECT CAST([1] AS [2]) AS [3];
Drag options to blanks, or click blank then click option'
A'2023-06-01 12:30:00'
BDATETIME
Cconverted
D'2023-06-01'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the date string loses time information.
Wrong alias names cause confusion.