BAB III
Bekerja dengan Operator dan Fungsi Matematik
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.67-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SELECT 10 * 6;
+--------+
| 10 * 6 |
+--------+
| 60 |
+--------+
1 row in set (0.02 sec)
mysql> SELECT 2.5 * 10;
+----------+
| 2.5 * 10 |
+----------+
| 25.0 |
+----------+
1 row in set (0.01 sec)
mysql> SELECT -5 * 10,
-> -5 * 10;
+---------+---------+
| -5 * 10 | -5 * 10 |
+---------+---------+
| -50 | -50 |
+---------+---------+
1 row in set (0.00 sec)
mysql> SELECT (9 / 3) * 2;
+-------------+
| (9 / 3) * 2 |
+-------------+
| 6.0000 |
+-------------+
1 row in set (0.01 sec)
mysql> SELECT 18 / 3;
+--------+
| 18 / 3 |
+--------+
| 6.0000 |
+--------+
1 row in set (0.00 sec)
mysql> SELECT 10 / 0.5;
+----------+
| 10 / 0.5 |
+----------+
| 20.0000 |
+----------+
1 row in set (0.00 sec)
mysql> SELECT 4 + 6;
+-------+
| 4 + 6 |
+-------+
| 10 |
+-------+
1 row in set (0.00 sec)
mysql> SELECT 2 + 4 * 2,
-> ( 2 + 4 ) * 2;
+-----------+---------------+
| 2 + 4 * 2 | ( 2 + 4 ) * 2 |
+-----------+---------------+
| 10 | 12 |
+-----------+---------------+
1 row in set (0.00 sec)
mysql> SELECT 2 + 5 * 3 + 2 ,
-> ( 2 + 5 ) * 3 + 2,
-> ( 2 + 5 ) * ( 3 + 2);
+---------------+-------------------+----------------------+
| 2 + 5 * 3 + 2 | ( 2 + 5 ) * 3 + 2 | ( 2 + 5 ) * ( 3 + 2) |
+---------------+-------------------+----------------------+
| 19 | 23 | 35 |
+---------------+-------------------+----------------------+
1 row in set (0.00 sec)
mysql> SELECT 10 - 6;
+--------+
| 10 - 6 |
+--------+
| 4 |
+--------+
1 row in set (0.02 sec)
mysql> SELECT 6 - 2 + 8,
-> ( 6 - 2 ) + 8 ,
-> 6 - ( 2 + 8 ) ;
+-----------+---------------+---------------+
| 6 - 2 + 8 | ( 6 - 2 ) + 8 | 6 - ( 2 + 8 ) |
+-----------+---------------+---------------+
| 12 | 12 | -4 |
+-----------+---------------+---------------+
1 row in set (0.00 sec)
mysql> SELECT 5 % 2;
+-------+
| 5 % 2 |
+-------+
| 1 |
+-------+
1 row in set (0.00 sec)
mysql> SELECT 7 % 2,7 % 3,
-> 7 % 4, 7 % 5;
+-------+-------+-------+-------+
| 7 % 2 | 7 % 3 | 7 % 4 | 7 % 5 |
+-------+-------+-------+-------+
| 1 | 1 | 3 | 2 |
+-------+-------+-------+-------+
1 row in set (0.00 sec)
mysql> SELECT 7000 / 900, 7000 % 900;
+------------+------------+
| 7000 / 900 | 7000 % 900 |
+------------+------------+
| 7.7778 | 700 |
+------------+------------+
1 row in set (0.00 sec)
mysql> SELECT RADIANS(30),
-> RADIANS(45),
-> RADIANS(60);
+-----------------+------------------+-----------------+
| RADIANS(30) | RADIANS(45) | RADIANS(60) |
+-----------------+------------------+-----------------+
| 0.5235987755983 | 0.78539816339745 | 1.0471975511966 |
+-----------------+------------------+-----------------+
1 row in set (0.03 sec)
mysql> SELECT RADIANS(30),
-> DEGREES(0.5235987755983);
+-----------------+--------------------------+
| RADIANS(30) | DEGREES(0.5235987755983) |
+-----------------+--------------------------+
| 0.5235987755983 | 30 |
+-----------------+--------------------------+
1 row in set (0.00 sec)
mysql> SELECT RADIANS(60),
-> DEGREES(1.0471976611966);
+-----------------+--------------------------+
| RADIANS(60) | DEGREES(1.0471976611966) |
+-----------------+--------------------------+
| 1.0471975511966 | 60.000006302536 |
+-----------------+--------------------------+
1 row in set (0.00 sec)
mysql> SELECT COS(RADIANS(30)),
-> COS(RADIANS(90));
+------------------+----------------------+
| COS(RADIANS(30)) | COS(RADIANS(90)) |
+------------------+----------------------+
| 0.86602540378444 | 6.1230317691119e-017 |
+------------------+----------------------+
1 row in set (0.00 sec)
mysql> SELECT SIN(RADIANS(45)),
-> SIN(RADIANS(60));
+------------------+------------------+
| SIN(RADIANS(45)) | SIN(RADIANS(60)) |
+------------------+------------------+
| 0.70710678118655 | 0.86602540378444 |
+------------------+------------------+
1 row in set (0.00 sec)
mysql> SELECT TAN(RADIANS(30)),
-> TAN(RADIANS(60));
+------------------+------------------+
| TAN(RADIANS(30)) | TAN(RADIANS(60)) |
+------------------+------------------+
| 0.57735026918963 | 1.7320508075689 |
+------------------+------------------+
1 row in set (0.00 sec)
mysql> SELECT ACOS(1),
-> COS(0);
+---------+--------+
| ACOS(1) | COS(0) |
+---------+--------+
| 0 | 1 |
+---------+--------+
1 row in set (0.00 sec)
mysql> SELECT ACOS(0.5),
-> COS(1.0471975511966),
-> COS(RADIANS(60));
+-----------------+----------------------+------------------+
| ACOS(0.5) | COS(1.0471975511966) | COS(RADIANS(60)) |
+-----------------+----------------------+------------------+
| 1.0471975511966 | 0.5 | 0.5 |
+-----------------+----------------------+------------------+
1 row in set (0.00 sec)
mysql> SELECT ASIN(0.5),
-> SIN(0.5235987755983),
-> SIN(RADIANS(30));
+-----------------+----------------------+------------------+
| ASIN(0.5) | SIN(0.5235987755983) | SIN(RADIANS(30)) |
+-----------------+----------------------+------------------+
| 0.5235987755983 | 0.5 | 0.5 |
+-----------------+----------------------+------------------+
1 row in set (0.00 sec)
mysql> SELECT ASIN(1),
-> SIN(1.5707963267949);
+-----------------+----------------------+
| ASIN(1) | SIN(1.5707963267949) |
+-----------------+----------------------+
| 1.5707963267949 | 1 |
+-----------------+----------------------+
1 row in set (0.00 sec)
mysql> SELECT ATAN(0.5),
-> TAN(0.46364760900081);
+------------------+-----------------------+
| ATAN(0.5) | TAN(0.46364760900081) |
+------------------+-----------------------+
| 0.46364760900081 | 0.5 |
+------------------+-----------------------+
1 row in set (0.00 sec)
-> ROUND(2.56);
+-------------+-------------+-------------+-------------+
| ROUND(2.45) | ROUND(2.50) | ROUND(2.51) | ROUND(2.56) |
+-------------+-------------+-------------+-------------+
| 2 | 3 | 3 | 3 |
+-------------+-------------+-------------+-------------+
1 row in set (0.00 sec)
mysql> SELECT ROUND(2.250, 1),
-> ROUND(2.251, 1),
-> ROUND(2.259, 1);
+-----------------+-----------------+-----------------+
| ROUND(2.250, 1) | ROUND(2.251, 1) | ROUND(2.259, 1) |
+-----------------+-----------------+-----------------+
| 2.3 | 2.3 | 2.3 |
+-----------------+-----------------+-----------------+
1 row in set (0.00 sec)
mysql> SELECT ROUND(2.250, 2),
-> ROUND(2.251, 2),
-> ROUND(2.259, 2);
+-----------------+-----------------+-----------------+
| ROUND(2.250, 2) | ROUND(2.251, 2) | ROUND(2.259, 2) |
+-----------------+-----------------+-----------------+
| 2.25 | 2.25 | 2.26 |
+-----------------+-----------------+-----------------+
1 row in set (0.00 sec)
mysql> SELECT ROUND(2.250, 0),
-> ROUND(2.251, 0),
-> ROUND(2.259, 0);
+-----------------+-----------------+-----------------+
| ROUND(2.250, 0) | ROUND(2.251, 0) | ROUND(2.259, 0) |
+-----------------+-----------------+-----------------+
| 2 | 2 | 2 |
+-----------------+-----------------+-----------------+
1 row in set (0.00 sec)
mysql> SELECT CEILING(2.23),
-> CEILING(2.55),
-> CEILING(2.90);
+---------------+---------------+---------------+
| CEILING(2.23) | CEILING(2.55) | CEILING(2.90) |
+---------------+---------------+---------------+
| 3 | 3 | 3 |
+---------------+---------------+---------------+
1 row in set (0.00 sec)
mysql> SELECT CEILING(-2.23),
-> CEILING(-2.55),
-> CEILING(-2.90);
+----------------+----------------+----------------+
| CEILING(-2.23) | CEILING(-2.55) | CEILING(-2.90) |
+----------------+----------------+----------------+
| -2 | -2 | -2 |
+----------------+----------------+----------------+
1 row in set (0.00 sec)
mysql> SELECT CEIL(-1.10) , CEIL(-1.99) ;
+-------------+-------------+
| CEIL(-1.10) | CEIL(-1.99) |
+-------------+-------------+
| -1 | -1 |
+-------------+-------------+
1 row in set (0.00 sec)
mysql> SELECT FLOOR(2.01) ,
-> FLOOR(2.45),
-> FLOOR(2.95);
+-------------+-------------+-------------+
| FLOOR(2.01) | FLOOR(2.45) | FLOOR(2.95) |
+-------------+-------------+-------------+
| 2 | 2 | 2 |
+-------------+-------------+-------------+
1 row in set (0.00 sec)
mysql> SELECT FLOOR(-2.01),
-> FLOOR(-2.45),
-> FLOOR(-2.95);
+--------------+--------------+--------------+
| FLOOR(-2.01) | FLOOR(-2.45) | FLOOR(-2.95) |
+--------------+--------------+--------------+
| -3 | -3 | -3 |
+--------------+--------------+--------------+
1 row in set (0.00 sec)
mysql> SELECT ABS(3),
-> ABS(-3),
-> ABS(-3.34) ;
+--------+---------+------------+
| ABS(3) | ABS(-3) | ABS(-3.34) |
+--------+---------+------------+
| 3 | 3 | 3.34 |
+--------+---------+------------+
1 row in set (0.00 sec)
mysql> SELECT 5 DIV 2,
-> 5 DIV 3,
-> 9 DIV 3;
+---------+---------+---------+
| 5 DIV 2 | 5 DIV 3 | 9 DIV 3 |
+---------+---------+---------+
| 2 | 1 | 3 |
+---------+---------+---------+
1 row in set (0.00 sec)
mysql> SELECT 5 / 2,
-> 5 / 3,
-> 9 / 3;
+--------+--------+--------+
| 5 / 2 | 5 / 3 | 9 / 3 |
+--------+--------+--------+
| 2.5000 | 1.6667 | 3.0000 |
+--------+--------+--------+
1 row in set (0.00 sec)
mysql> SELECT MOD(5.2) ,
-> MOD(5, 3) ,
-> MOD(9, 3) ;
mysql> SELECT MOD(5,2),
-> MOD(5, 3),
-> MOD(9, 3);
+----------+-----------+-----------+
| MOD(5,2) | MOD(5, 3) | MOD(9, 3) |
+----------+-----------+-----------+
| 1 | 2 | 0 |
+----------+-----------+-----------+
1 row in set (0.00 sec)
mysql> SELECT 5 % 22,
-> 5 % 3,
-> 9 % 3;
+--------+-------+-------+
| 5 % 22 | 5 % 3 | 9 % 3 |
+--------+-------+-------+
| 5 | 2 | 0 |
+--------+-------+-------+
1 row in set (0.00 sec)
mysql> SELECT POW(2, 3),
-> POWER(2, 4),
-> POWER(4, 2);
+-----------+-------------+-------------+
| POW(2, 3) | POWER(2, 4) | POWER(4, 2) |
+-----------+-------------+-------------+
| 8 | 16 | 16 |
+-----------+-------------+-------------+
1 row in set (0.03 sec)
mysql> SELECT RAND();
+------------------+
| RAND() |
+------------------+
| 0.15733176111926 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT RAND(2),
-> RAND(10),
-> RAND(20);
+------------------+------------------+------------------+
| RAND(2) | RAND(10) | RAND(20) |
+------------------+------------------+------------------+
| 0.65558664654902 | 0.65705152196535 | 0.15888261251047 |
+------------------+------------------+------------------+
1 row in set (0.00 sec)
mysql> SELECT SQRT(81);
+----------+
| SQRT(81) |
+----------+
| 9 |
+----------+
1 row in set (0.00 sec)
mysql> SELECT 9 * 9 ;
+-------+
| 9 * 9 |
+-------+
| 81 |
+-------+
1 row in set (0.00 sec)
mysql> SELECT SQRT(4),
-> SQRT(9),
-> SQRT(16),
-> SQRT(25);
+---------+---------+----------+----------+
| SQRT(4) | SQRT(9) | SQRT(16) | SQRT(25) |
+---------+---------+----------+----------+
| 2 | 3 | 4 | 5 |
+---------+---------+----------+----------+
1 row in set (0.00 sec)
mysql> SELECT LEAST(1, 2, 3, 4, 5, 6, 7, 8 , 9);
+-----------------------------------+
| LEAST(1, 2, 3, 4, 5, 6, 7, 8 , 9) |
+-----------------------------------+
| 1 |
+-----------------------------------+
1 row in set (0.03 sec)
mysql> SELECT LEAST(7, 3, 5, 2, 3, 9,8);
+---------------------------+
| LEAST(7, 3, 5, 2, 3, 9,8) |
+---------------------------+
| 2 |
+---------------------------+
1 row in set (0.00 sec)
mysql> SELECT LEAST('E','B','C','F');
+------------------------+
| LEAST('E','B','C','F') |
+------------------------+
| B |
+------------------------+
1 row in set (0.00 sec)
mysql> SELECT GREATEST(1, 2, 3, 4, 5, 6, 7, 8, 9);
+-------------------------------------+
| GREATEST(1, 2, 3, 4, 5, 6, 7, 8, 9) |
+-------------------------------------+
| 9 |
+-------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT GREATEST(7, 3, 5, 2, 3, 9, 8);
+-------------------------------+
| GREATEST(7, 3, 5, 2, 3, 9, 8) |
+-------------------------------+
| 9 |
+-------------------------------+
1 row in set (0.00 sec)
mysql> SELECT GREATEST('E','B','C','F');
+---------------------------+
| GREATEST('E','B','C','F') |
+---------------------------+
| F |
+---------------------------+
1 row in set (0.00 sec)
mysql> SELECT PI();
+----------+
| PI() |
+----------+
| 3.141593 |
+----------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(1.245, 1),
-> TRUNCATE(5.23, 1);
+--------------------+-------------------+
| TRUNCATE(1.245, 1) | TRUNCATE(5.23, 1) |
+--------------------+-------------------+
| 1.2 | 5.2 |
+--------------------+-------------------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(1.245, 2),
-> TRUNCATE(2.459890, 4);
+--------------------+-----------------------+
| TRUNCATE(1.245, 2) | TRUNCATE(2.459890, 4) |
+--------------------+-----------------------+
| 1.24 | 2.4598 |
+--------------------+-----------------------+
1 row in set (0.00 sec)
mysql> SELECT POWER(2, 4),
-> LOG(16);
+-------------+-----------------+
| POWER(2, 4) | LOG(16) |
+-------------+-----------------+
| 16 | 2.7725887222398 |
+-------------+-----------------+
1 row in set (0.00 sec)
mysql> SELECT POWER(2, 7),
-> LOG2(128);
+-------------+-----------+
| POWER(2, 7) | LOG2(128) |
+-------------+-----------+
| 128 | 7 |
+-------------+-----------+
1 row in set (0.00 sec)
mysql> SELECT POWER(2, 4),
-> LOG2(16);
+-------------+----------+
| POWER(2, 4) | LOG2(16) |
+-------------+----------+
| 16 | 4 |
+-------------+----------+
1 row in set (0.00 sec)
BAB II
Proses Installasi MySQL