MySQL

    MySQL- is null : null인 데이터를 가져오는 방법

    comments 테이블은 위 사진과 같습니다. is null -- comments 테이블에서 updated_at 컬럼이 null인 데이터를 가져오시오. select * from comments where updated_at is null; is not null -- comments 테이블에서 updated_at 컬럼이 null이 아닌 데이터를 가져오시오. select * from comments where updated_at is not null;

    MySQL - date_format, 시간차이 datediff, 날짜 더하기date_add 사용하기

    insert into people2 (name,birthdate,birthtime,birthdt) values ('Mike','1990-11-11','10:07:35','1983-11-11 10:07:35'), ('Larry','1972-12-25','04:10:42','1990-12-25 04:10:42'); -- db에 저장된 시간형식의 데이터를 -- 사람이 보기 편한 데이터로 바꾸는 방법 date_format() select date_format(birthdt,'%Y년 %m월 %d일,%h시%m분%s초') from people2; - 시간의 차이를 구하는 방법 datediff() => 날짜로 select datediff( now() , birthdt ) from people2; date_add() s..

    MySQL - 의 현재 Datetime 정보 가져오는 함수 curdate(), curtime(),now()

    지금 현재의 시간과 날짜를 가져오는 함수가 있다. -- 현재의 연월일 정보를 가져오는 함수 curdate() select curdate(); -- 현재의 시간을 가져오는 함수 curtime() select curtime(); -- 현재의 연월일 시분초를 가져오는 함수 now() select now(); 시간은 UTC 시간 협정 세계시 로 출력 되기 때문에 9시간 차이가 나게 된다.

    MySQL - 날짜와 시간 처리 datetime테이블 설정 및 원하는 연,월,일,요일 출력

    테이블을 만들때 Datatype을 설정해줍니다. DATE는 날짜만 출력하고 TIME은 시간만 출력, DATETIME은 두개 전부 출력합니다. use YHDB; insert into people2 (name,birthdate,birthtime,birthdt) values ('Mike','1990-11-11','10:07:35','1990-11-11 10:07:35'), ('Larry','1972-12-25','04:10:42','1972-12-25 04:10:42'); select * from people2; -- 날짜 정보만 가져오기 select name,day(birthdate) from people2; select name,dayname(birthdate) -- 해당 날짜의 요일 출력 from peo..