|
Home >> FAQs/Tutorials >> MySQL Tutorials >> Index
MySQL FAQs - Introduction to SQL Basics
By: FYIcenter.com
Part:
1
2
3
4
5
6
7
(Continued from previous part...)
How To Include Numeric Values in SQL statements?
If you want to include a numeric value in your SQL statement, you can enter
it directly as shown in the following examples:
SELECT 255 FROM DUAL; -- An integer
255
SELECT -6.34 FROM DUAL; -- A regular number
-6.34
SELECT -32032.6809e+10 FROM DUAL; -- A floating-point value
-3.20326809e+014
How To Enter Characters as HEX Numbers?
If you want to enter characters as HEX numbers, you can quote HEX numbers
with single quotes and a prefix of (X), or just prefix HEX numbers with (0x).
A HEX number string will be automatically converted into a character string,
if the expression context is a string. Here are some good examples:
SELECT X'313233' FROM DUAL;
123
SELECT 0x414243 FROM DUAL;
ABC
SELECT 0x46594963656E7465722E636F6D FROM DUAL;
FYIcenter.com
How To Enter Numeric Values as HEX Numbers?
If you want to enter numeric values as HEX numbers, you can quote HEX numbers
with single quotes and a prefix of (X), or just prefix HEX numbers with (0x).
A HEX number string will be automatically converted into a numeric value,
if the expression context is a numeric value. Here are some good examples:
SELECT X'10' + 16 FROM DUAL;
32
SELECT 0x1000 + 0 FROM DUAL;
4096
How To Enter Binary Numbers in SQL Statements?
If you want to enter character strings or numeric values as binary numbers,
you can quote binary numbers with single quotes and a prefix of (B), or just
prefix binary numbers with (0b). Binary numbers will be automatically converted
into character strings or numeric values based on the expression contexts.
Here are some good examples:
SELECT B'010000010100001001000011' FROM DUAL;
ABC
SELECT 0b1000 + 0 FROM DUAL;
8
How To Enter Boolean Values in SQL Statements?
If you want to enter Boolean values in SQL statements, you use (TRUE), (FALSE),
(true), or (false). Here are some good examples:
SELECT TRUE, true, FALSE, false FROM DUAL;
+------+------+-------+-------+
| TRUE | TRUE | FALSE | FALSE |
+------+------+-------+-------+
| 1 | 1 | 0 | 0 |
+------+------+-------+-------+
(Continued on next part...)
Part:
1
2
3
4
5
6
7
|