티스토리 뷰
concat과 time을 사용하여 날짜변경 (년,월,일 ... ) 쉽게 변환하기
concat
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent nonbinary string form.
CONCAT() returns NULL if any argument is NULL.
mysql> SELECT CONCAT('My', 'S', 'QL');
-> 'MySQL'
mysql> SELECT CONCAT('My', NULL, 'QL');
-> NULL
mysql> SELECT CONCAT(14.3);
-> '14.3'For quoted strings, concatenation can be performed by placing the strings next to each other:
mysql> SELECT 'My' 'S' 'QL';
-> 'MySQL'https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat
time
Extracts the time part of the time or datetime expression expr and returns it as a string.
This function is unsafe for statement-based replication. A warning is logged if you use this function when binlog_format is set to STATEMENT.
mysql> SELECT TIME('2003-12-31 01:02:03');
-> '01:02:03'
mysql> SELECT TIME('2003-12-31 01:02:03.000123');
-> '01:02:03.000123'SQL Query
1 | update MY_TABLE set datetime = concat('2018-08-12 ', time(datetime)) | cs |
'■ Database ■ > MySQL' 카테고리의 다른 글
| 원격접속을 위한 방화벽, 계정 설정 (0) | 2020.11.04 |
|---|---|
| IF, ISNULL (0) | 2018.11.22 |
| date, date_format 을 사용한 날짜 비교 (0) | 2018.11.13 |
| foreign key (0) | 2018.06.28 |
| Mysql 접속 에러 Host is not allowed to connect to this Mysql server 혹은 Access denied for user (0) | 2018.03.16 |