MySQL 26

MySQL WorkBench 에 AWS DB 설정하기

+ 버튼을 눌러주세요 https://dbfoot.tistory.com/151?category=1248160 AWS Free Tier 설치하기 https://aws.amazon.com/ko/free/?trk=fa2d6ba3-df80-4d24-a453-bf30ad163af9&sc_channel=ps&sc_campaign=acquisition&sc_medium=ACQ-P|PS-GO|Brand|Desktop|SU|Core-Main|Core|KR|KR|Text&ef_id=Cj0KCQiAuvOPBhDX.. dbfoot.tistory.com 여기서 만들었던 프리티어를 사용하겠습니다. 프리티어 만들때 설정했던 username과 포트 번호 엔드포인트를 Hostname에 넣어줍니다. 그리고 Store in Keychain..

MySQL 2022.02.04

MySQL의 테이블 합치기 inner join, outer join(right, left)와 ifnull 이용해 null값 변경

INSERT INTO students (first_name) VALUES ('Caleb'), ('Samantha'), ('Raj'), ('Carlos'), ('Lisa'); INSERT INTO papers (student_id, title, grade ) VALUES (1, 'My First Book Report', 60), (1, 'My Second Book Report', 75), (2, 'Russian Lit Through The Ages', 94), (2, 'De Montaigne and The Art of The Essay', 98), (4, 'Borges and Magical Realism', 89); 먼저 데이터를 입력해줍니다. students테이블은 id(int), first_name(v..

MySQL 2021.12.16

MySQL의 테이블 코딩 작성하기 create table

workbench를 사용하지 않고 테이블 생성 코딩 create table comments( -- 테이블 생성 테이블 이름 comment content varchar(100), -- content 컬럼 데이터타입은 varchar 100글자 created_at timestamp default now() -- created_at 컬럼 데이터타입은 timestamp 기본값은 now() 현재시간 ); 이렇게 하시면 테이블이 생성됩니다. 테이블에 값을 넣어보기 insert into insert into comments (content) -- comment 테이블에 content 컬럼에 values ('안녕하세요'); -- 안녕하세요 데이터를 넣는다. 생성한 테이블 보기 select * from comments; ..

MySQL 2021.12.10

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

테이블을 만들때 Datatype을 설정해줍니다. DATE는 날짜만 출력하고 TIME은 시간만 출력, DATETIME은 두개 전부 출력합니다. insert into people2 (name,birthdate,birthtime,birthdt) values ('Padma','1983-11-11','10:07:35','1983-11-11 10:07:35'), ('Larry','1990-12-25','04:10:42','1990-12-25 04:10:42'); date_format 이용해서 출력하기 select date_format(birthdt,'저는 %m/%d/%Y에 태어났습니다.') as Introduce from people2; select date_format(birthdt, '%h:%i에 태어났습니다...

MySQL 2021.12.09

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

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

MySQL 2021.12.09

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

테이블을 만들때 Datatype을 설정해줍니다. DATE는 날짜만 출력하고 TIME은 시간만 출력, DATETIME은 두개 전부 출력합니다. insert into people2 (name,birthdate,birthtime,birthdt) values ('Padma','1983-11-11','10:07:35','1983-11-11 10:07:35'), ('Larry','1990-12-25','04:10:42','1990-12-25 04:10:42'); 위 데이터에서 날짜만 출력 select name,day(birthdate) from people2; 위 날짜 데이터의 요일을 출력 select name,dayname(birthdate) -- 해당 날짜의 요일 출력 from people2; select na..

MySQL 2021.12.09

MySQL의 모든 데이터 값을 더하는 sum()함수와 평균을 구하는 avg()함수

예시 문) INSERT INTO books (title, author_fname, author_lname, released_year, stock_quantity, pages) VALUES ('The Namesake', 'Jhumpa', 'Lahiri', 2003, 32, 291), ('Norse Mythology', 'Neil', 'Gaiman',2016, 43, 304), ('American Gods', 'Neil', 'Gaiman', 2001, 12, 465), ('Interpreter of Maladies', 'Jhumpa', 'Lahiri', 1996, 97, 198), ('A Hologram for the King: A Novel', 'Dave', 'Eggers', 2012, 154, 352),..

MySQL 2021.12.09