mysql> SELECT ROUND(-1.23);
-> -1
mysql> SELECT ROUND(-1.58);
-> -2
mysql> SELECT ROUND(1.58);
-> 2
mysql> SELECT ROUND(1.298, 1);
-> 1.3
mysql> SELECT ROUND(1.298, 0);
-> 1
mysql> SELECT ROUND(23.298, -1);
-> 20
mysql> SELECT TRUNCATE(1.223,1);
-> 1.2
mysql> SELECT TRUNCATE(1.999,1);
-> 1.9
mysql> SELECT TRUNCATE(1.999,0);
-> 1
mysql> SELECT TRUNCATE(-1.999,1);
-> -1.9
mysql> SELECT TRUNCATE(122,-2);
-> 100
mysql> SELECT TRUNCATE(10.28*100,0);
-> 1028
mysql> SELECT CEIL(1.23);
-> 2
mysql> SELECT CEIL(-1.23);
-> -1
mysql> SELECT CEIL(8.765);
-> 9
mysql> SELECT FLOOR(1.23), FLOOR(-1.23);
-> 1, -2
mysql> SELECT FLOOR(8.765);
-> 8
mysql> SELECT POW(2,2);
-> 4
mysql> SELECT POWER(8,1/3); -- 값의 N 제곱근 = 값의 1/N제곱 = POWER(X,1/N)
-> 2
mysql> SELECT POW(2,-2);
-> 0.25
mysql> SELECT SQRT(4);
-> 2
mysql> SELECT SQRT(20);
-> 4.4721359549996
mysql> SELECT SQRT(-16);
-> NULL
mysql> SELECT MOD(234, 10);
-> 4
mysql> SELECT 253 % 7;
-> 1
mysql> SELECT MOD(29,9);
-> 2
mysql> SELECT 29 MOD 9;
-> 2
mysql> SELECT ABS(2);
-> 2
mysql> SELECT ABS(-32);
-> 32
mysql> SELECT ABS(-4,5);
-> 4.5
📖 MySQL 숫자 함수 정리: https://dev.mysql.com/doc/refman/8.1/en/mathematical-functions.html
mysql> SELECT LOWER('QUADRATICALLY');
-> 'quadratically'
mysql> SELECT UPPER('Hej');
-> 'HEJ'
mysql> SELECT REPLACE('www.mysql.com', 'w', 'Ww');
-> 'WwWwWw.mysql.com'
SELECT REPLACE(ID, 'D', 'B') AS ID
ID |
---|
ID1 |
ID2 |
ID3 |
🔽
ID |
---|
IB1 |
IB2 |
IB3 |
mysql> SELECT CONCAT('My', 'S', 'QL');
-> 'MySQL'
mysql> SELECT CONCAT('My', NULL, 'QL');
-> NULL
mysql> SELECT CONCAT(14.3);
-> '14.3'
SELECT CONCAT(NUM, '-', ID) AS ID
NUM | ID |
---|---|
1 | ID1 |
2 | ID2 |
3 | ID3 |
🔽
ID |
---|
1-ID1 |
2-ID2 |
3-ID3 |
📖 MySQL 문자 함수 정리: https://dev.mysql.com/doc/refman/8.1/en/string-functions.html