728x90
MySQL - Update 질의문 사용시 조회된 결과로 반영
출처 : MySQL - UPDATE query based on SELECT Query
update item_code a left join item_type b on a.type_name like ( concat('%', b.type_name , '%') ) set a.type_id = b.id
UPDATE code_type a LEFT OUTER JOIN code_group b ON a.g_id = b.id AND b.category_id in ('M', 'E') SET a.t_code = CONCAT(b.g_code, SUBSTR(a.t_code, 4, 2)) WHERE a.g_id = b.id AND b.category_id in ('M', 'E')
MySQL - 날짜 연산
출처 : 12.7 Date and Time Functions
mysql> select now(), date_sub(now(), interval 1 DAY); +---------------------+---------------------------------+ | now() | date_sub(now(), interval 1 DAY) | +---------------------+---------------------------------+ | 2015-12-03 23:44:52 | 2015-12-02 23:44:52 | +---------------------+---------------------------------+ 1 row in set (0.00 sec)
MySQL - DATETIME 타입을 DATE 타입으로 형변환
select * from memo1 where survey_date = cast(now() as DATE)
-
728x90