
JOIN JOIN JOIN은 데이터베이스 내의 여러 테이블에서 가져온 레코드를 조합하여 하나의 테이블이나 결과 집합으로 표현해 줍니다. 이러한 JOIN은 보통 SELECT 문과 함께 자주 사용됩니다. 표준 SQL에서는 레코드를 조합하는 방식에 따라 JOIN을 다음과 같이 구분합니다. 1. INNER JOIN 2. LEFT JOIN 3. RIGHT JOIN INNER JOIN INNER JOIN은 ON 절과 함께 사용되며, ON 절의 조건을 만족하는 데이터만을 가져옵니다. 문법 1. 첫번째테이블이름 INNER JOIN 두번째테이블이름 ON 조건 2. 첫번째테이블이름 JOIN 두번째테이블이름 ON 조건 ON 절에서는 WHERE 절에서 사용할 수 있는 모든 조건을 사용할 수 있습니다. 표준 SQL과는 달리 M..

테이블 합치기 JOIN 사용하기 SELECT 필드명 FROM 테이블명 엘리어스 JOIN 연결할 테이블명 엘리어스 (ON)조건문; SELECT m.youName, m.youEmail, r.youCont, r.regTime FROM myMember m JOIN myReview r ON(m.memberID = r.memberID); CREATE TABLE myMember ( memberID int(10) unsigned auto_increment, youEmail varchar(40) NOT NULL, youName varchar(20) NOT NULL, youPass varchar(20) NOT NULL, youBirth int(20) NOT NULL, youAge int(20) NOT NULL, youPh..

테이블 데이터 데이터 입력하기 INSERT INTO 테이블 이름(필드명) VALUES(데이터); INSERT INTO myMember(youEmail, youName, youPass, youBirth, youAge, youPhone, regTime) VALUES('ik6623@naver.com','박종호','1234qwer','19950909','28','01040976623','10293857'); INSERT INTO myMember(youEmail, youName, youPass, youBirth, youAge, youPhone, regTime) VALUES('webstoryboy@naver.com','황상연','12dfsdecv','19920405','33','01039858583','578365..

필드 추가하기 ALTER TABLE 테이블 명 ADD 추가할 필드명 AFTER 필드명 위치; ALTER TABLE myMember ADD youGender enum('m','w','x') default 'x' comment "남성은 m, 여성은 w" AFTER youBirth; Query OK, 0 rows affected (0.05 sec) mysql> desc myMember; +----------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+------------------+------+-----+---------+---------..

테이블 만들기 create table 테이블 이름; CREATE TABLE myMember ( memberID int(10) unsigned auto_increment, youEmail varchar(40) NOT NULL, youName varchar(20) NOT NULL, youPass varchar(20) NOT NULL, youBirth int(20) NOT NULL, youAge int(20) NOT NULL, youPhone int(20) NOT NULL, regTime int(11) NOT NULL, PRIMARY KEY (memberID) ) charset=utf8; 테이블 전체 보기 show tables; mysql> show tables; +--------------------+ | ..

데이터 베이스 데이터 베이스 만들기 create database 데이터베이스 이름: mysql> create database sample01; Query OK, 1 row affected (0.00 sec) 데이터 베이스 보기 show databases; mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sample01 | | sys | +--------------------+ 5 rows in set (0.00 sec) 데이터 베이스 사용 use 데이터베이스 이름; mysql> use sample01; D..

C:\MAMP\bin\mysql\bin>mysql -uroot -proot mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.7.24 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/..