0% found this document useful (0 votes)
13 views4 pages

Mysql Taniaaaaaaaaa (01 Des)

The document contains examples of MySQL functions such as ASCII, CHAR, BIN, OCT, HEX, CONV, LENGTH, CHAR_LENGTH, CONCAT, ELT, FIELD, FIND_IN_SET, FORMAT, and INSERT. It demonstrates how to use these functions to operate on and retrieve information from strings, numbers, and NULL values.

Uploaded by

NANA TANIA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Mysql Taniaaaaaaaaa (01 Des)

The document contains examples of MySQL functions such as ASCII, CHAR, BIN, OCT, HEX, CONV, LENGTH, CHAR_LENGTH, CONCAT, ELT, FIELD, FIND_IN_SET, FORMAT, and INSERT. It demonstrates how to use these functions to operate on and retrieve information from strings, numbers, and NULL values.

Uploaded by

NANA TANIA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

mysql> SELECT ASCII('A'),ASCII('a');

+------------+------------+
| ASCII('A') | ASCII('a') |
+------------+------------+
| 65 | 97 |
+------------+------------+
1 row in set (0.01 sec)

mysql> SELECT ASCII(1),ASCII(NULL),ASCII(' ');


+----------+-------------+------------+
| ASCII(1) | ASCII(NULL) | ASCII(' ') |
+----------+-------------+------------+
| 49 | NULL | 32 |
+----------+-------------+------------+
1 row in set (0.00 sec)

mysql> SELECT CHAR(65),CHAR(97),CHAR(3);


+----------+----------+---------+
| CHAR(65) | CHAR(97) | CHAR(3) |
+----------+----------+---------+
| A | a | ♥ |
+----------+----------+---------+
1 row in set (0.00 sec)

mysql> SELECT BIN(1),BIN(6),BIN(3456),BIN('arbie');


+--------+--------+--------------+--------------+
| BIN(1) | BIN(6) | BIN(3456) | BIN('arbie') |
+--------+--------+--------------+--------------+
| 1 | 110 | 110110000000 | 0 |
+--------+--------+--------------+--------------+
1 row in set (0.00 sec)

mysql> SELECT OCT(8),OCT(16),SELECT(22);


ERROR 1064 (42000): You have an error in your SQL syntax;
corresponds to your MySQL server version for the right syn
T(22)' at line 1
mysql> SELECT OCT(8),OCT(16),OCT(22);
+--------+---------+---------+
| OCT(8) | OCT(16) | OCT(22) |
+--------+---------+---------+
| 10 | 20 | 26 |
+--------+---------+---------+
1 row in set (0.00 sec)

mysql> SELECT HEX(17),HEX(123),HEX(10000);


+---------+----------+------------+
| HEX(17) | HEX(123) | HEX(10000) |
+---------+----------+------------+
| 11 | 7B | 2710 |
+---------+----------+------------+
1 row in set (0.00 sec)
mysql> SELECT HEX(255),HEX(123),HEX(10000);
+----------+----------+------------+
| HEX(255) | HEX(123) | HEX(10000) |
+----------+----------+------------+
| FF | 7B | 2710 |
+----------+----------+------------+
1 row in set (0.00 sec)

mysql> SELECT CONV(11001, 2, 16);


+--------------------+
| CONV(11001, 2, 16) |
+--------------------+
| 19 |
+--------------------+
1 row in set (0.00 sec)

mysql> SELECT CONV(11111111,2,10);


+---------------------+
| CONV(11111111,2,10) |
+---------------------+
| 255 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT CONV(255,10,16),CONV(123,10,16),CONV(10000,1


+-----------------+-----------------+-------------------+
| CONV(255,10,16) | CONV(123,10,16) | CONV(10000,10,16) |
+-----------------+-----------------+-------------------+
| FF | 7B | 2710 |
+-----------------+-----------------+-------------------+
1 row in set (0.00 sec)

mysql> SELECT CONV('FF',16,10),CONV('7B',16,10),CONV('2710


+------------------+------------------+-------------------
| CONV('FF',16,10) | CONV('7B',16,10) | CONV('2710',16,10)
+------------------+------------------+-------------------
| 255 | 123 | 10000
+------------------+------------------+-------------------
1 row in set (0.00 sec)

mysql> SELECT LENGTH('INDONESIA MERDEKA');


+-----------------------------+
| LENGTH('INDONESIA MERDEKA') |
+-----------------------------+
| 17 |
+-----------------------------+
1 row in set (0.00 sec)

mysql> SELECT CHAR_LENGTH('abc'),CHAR_LENGTH('matahari');


+--------------------+-------------------------+
| CHAR_LENGTH('abc') | CHAR_LENGTH('matahari') |
+--------------------+-------------------------+
| 3 | 8 |
+--------------------+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT CONCAT('mata','hari');


+-----------------------+
| CONCAT('mata','hari') |
+-----------------------+
| matahari |
+-----------------------+
1 row in set (0.00 sec)

mysql> SELECT CONCAT('mata','hari'), CONCAT('matahari',NUL


+-----------------------+-------------------------+
| CONCAT('mata','hari') | CONCAT('matahari',NULL) |
+-----------------------+-------------------------+
| matahari | NULL |
+-----------------------+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT ELT(2,'x','y','z','a','b','c');


+--------------------------------+
| ELT(2,'x','y','z','a','b','c') |
+--------------------------------+
| y |
+--------------------------------+
1 row in set (0.00 sec)

mysql> SELECT ELT(2,'x','y','z','a','b','c'),ELT(8,'x','y'


+--------------------------------+------------------------
| ELT(2,'x','y','z','a','b','c') | ELT(8,'x','y','z','a','
+--------------------------------+------------------------
| y | NULL
+--------------------------------+------------------------
1 row in set (0.00 sec)

mysql> SELECT FIELD('d','a','c','d','z'), FIELD('z','a','c


+----------------------------+------------------------+
| FIELD('d','a','c','d','z') | FIELD('z','a','c','d') |
+----------------------------+------------------------+
| 3 | 0 |
+----------------------------+------------------------+
1 row in set (0.00 sec)

mysql> SELECT FIELD('z','a','c','d','z'), FIELD('z','a','c


+----------------------------+------------------------+
| FIELD('z','a','c','d','z') | FIELD('z','a','c','d') |
+----------------------------+------------------------+
| 4 | 0 |
+----------------------------+------------------------+
1 row in set (0.00 sec)
mysql> SELECT FIND_IN_SET('ada','bunga,mawar,ada,lima');
+-------------------------------------------+
| FIND_IN_SET('ada','bunga,mawar,ada,lima') |
+-------------------------------------------+
| 3 |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT FORMAT(123456789,0),FORMAT(123456789,2);


+---------------------+---------------------+
| FORMAT(123456789,0) | FORMAT(123456789,2) |
+---------------------+---------------------+
| 123,456,789 | 123,456,789.00 |
+---------------------+---------------------+
1 row in set (0.00 sec)

mysql> SELECT INSERT("matahari", 5, 3, "herna");


+-----------------------------------+
| INSERT("matahari", 5, 3, "herna") |
+-----------------------------------+
| matahernai |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT INSERT("mathari", 5, 3, "herna");


+----------------------------------+
| INSERT("mathari", 5, 3, "herna") |
+----------------------------------+
| mathherna |
+----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT INSERT("matahari", 5, 2, "herna");


+-----------------------------------+
| INSERT("matahari", 5, 2, "herna") |
+-----------------------------------+
| matahernari |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT INSERT("mahari", 5, 2, "herna");


+---------------------------------+
| INSERT("mahari", 5, 2, "herna") |
+---------------------------------+
| mahaherna |
+---------------------------------+
1 row in set (0.00 sec)

mysql> SELECT INSERT("matahari", 5, 2, "herna");

You might also like