MySQL은 데이터베이스 소프트웨어입니다. 일반적으로 데이터를 추가하거나 검색, 추출하는 기능을 모두 포함해서 데이터베이스라고 부릅니다.

"MySQL은 세계에서 가장 많이 쓰이는 오픈 소스의 관계형 데이터베이스 관리 시스템(RDBMS)입니다. MySQL은 PHP 스크립트 언어와 상호 연동이 잘 되면서 오픈소스로 개발된 무료 프로그램입니다. 그래서 홈페이지나 쇼핑몰(워드프레스, cafe24, 제로보드, 그누보드) 등 일반적으로 웹 개발에 널리 사용하고 있습니다."

MAMP 설치

MAMP 설치완료 이미지입니다.

MAMP 실행

윈도우 : C:\MAMP\bin\mysql\bin
윈도우 : mysql -uroot -proot
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 4
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/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
맥 : cd /Application/mamp/Library/bin
맥 : sudo mysql -uroot -proot
webstoryboyhwang@Webstoryboyui-MacBookPro bin % sudo ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 383
Server version: 5.7.32 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

데이터베이스 만들기

CREATE DATABASE 데이터베이스 이름
mysql> create database test01;
Query OK, 1 row affected (0.00 sec)

데이터베이스 보기

SHOW DATABASES;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test01             |
| test02             |
+--------------------+
6 rows in set (0.00 sec)

데이터베이스 사용

USE 데이터베이스 이름;
mysql> use test01;
Database changed

데이터베이스 삭제

DROP DATABASE 삭제할 데이터베이스 이름
mysql> DROP DATABASE test02;
Query OK, 1 row affected (0.03 sec)

테이블 만들기

CREATE TABLE 테이블 이름;
CREATE TABLE myMember (
    myMemberID int(10) unsigned auto_increment comment "회원의 고유번호",
    youEmail varchar(40) NOT NULL comment "회원 아이디",
    youName varchar(12) NOT NULL comment "회원 이름",
    youPass varchar(20) NOT NULL comment "회원 비밀번호",
    youBirth varchar(11) NOT NULL comment "회원 생일",
    regTime int(11) NOT NULL comment "회원 가입 시간",
    PRIMARY KEY (myMemberID)
) charset=utf8 comment "회원 정보 테이블";

테이블 전체 보기

SHOW TABLES;
mysql> show tables;
+------------------+
| Tables_in_test01 |
+------------------+
| mymember         |
+------------------+
1 row in set (0.00 sec)

테이블 보기

DESC 테이블 이름;
mysql> desc myMember;
+------------+------------------+------+-----+---------+----------------+
| Field      | Type             | Null | Key | Default | Extra          |
+------------+------------------+------+-----+---------+----------------+
| myMemberID | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| youEmail   | varchar(40)      | NO   |     | NULL    |                |
| youName    | varchar(12)      | NO   |     | NULL    |                |
| youPass    | varchar(20)      | NO   |     | NULL    |                |
| youBirth   | varchar(11)      | NO   |     | NULL    |                |
| regTime    | int(11)          | NO   |     | NULL    |                |
+------------+------------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)

테이블 삭제

DROP TABLE 삭제할 테이블 이름;
mysql> drop table mymember;
Query OK, 0 rows affected (0.01 sec)

필드 추가하기

ALTER TABLE 테이블명 ADD 추가할 필드명 AFTER 필드 위치;
mysql> ALTER TABLE mymember ADD youGender enum('m','w','x') default 'x' comment "남성은 m, 여성은 w" AFTER youPhone;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc mymember2;
+------------+-------------------+------+-----+---------+----------------+
| Field      | Type              | Null | Key | Default | Extra          |
+------------+-------------------+------+-----+---------+----------------+
| myMemberID | int(10) unsigned  | NO   | PRI | NULL    | auto_increment |
| youEmail   | varchar(40)       | NO   |     | NULL    |                |
| youName    | varchar(12)       | NO   |     | NULL    |                |
| youPass    | varchar(20)       | NO   |     | NULL    |                |
| youBirth   | varchar(11)       | NO   |     | NULL    |                |
| youAge     | int(3)            | NO   |     | NULL    |                |
| youPhone   | int(11)           | NO   |     | NULL    |                |
| youGender  | enum('m','w','x') | YES  |     | x       |                |
| regTime    | int(11)           | NO   |     | NULL    |                |
+------------+-------------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)

필드 수정하기

ALTER TABLE 테이블 명 MODIFY 수정할 필드명;
mysql> ALTER TABLE mymember ADD youAge int(3) NOT NULL comment "회원의 나이" AFTER youBirth;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0
mysql> ALTER TABLE mymember ADD youPhone int(11) NOT NULL comment "회원의 폰넘 버" AFTER youAge;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0
mysql> ALTER TABLE mymember MODIFY youGender enum('m','w');
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc mymember;
+------------+------------------+------+-----+---------+----------------+
| Field      | Type             | Null | Key | Default | Extra          |
+------------+------------------+------+-----+---------+----------------+
| myMemberID | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| youEmail   | varchar(40)      | NO   |     | NULL    |                |
| youName    | varchar(12)      | NO   |     | NULL    |                |
| youPass    | varchar(20)      | NO   |     | NULL    |                |
| youBirth   | varchar(11)      | NO   |     | NULL    |                |
| youAge     | int(3)           | NO   |     | NULL    |                |
| youPhone   | int(11)          | NO   |     | NULL    |                |
| youGender  | enum('m','w')    | YES  |     | NULL    |                |
| regTime    | int(11)          | NO   |     | NULL    |                |
+------------+------------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)

필드 삭제하기

ALTER TABLE 삭제할 테이블명 DROP 삭제할 필드명;
mysql> ALTER TABLE mymember DROP youAge;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

데이터 입력하기

INSERT INTO 테이블 이름(필드명) VALUES(데이터);
mysql> INSERT INTO mymember(youEmail, youName, youPass, youBirth, regTime) VALUES('gkfl8809@naver','kdong','1234','1993-12-24','123');
Query OK, 1 row affected (0.00 sec)

데이터 불러오기

SELECT * FROM 테이블명;

전체 데이터 불러오기

mysql> SELECT * FROM mymember;
+------------+----------------+---------+---------+------------+---------+
| myMemberID | youEmail       | youName | youPass | youBirth   | regTime |
+------------+----------------+---------+---------+------------+---------+
|          1 | gkfl8809@naver | kdong   | 1234    | 1993-12-24 |     123 |
+------------+----------------+---------+---------+------------+---------+
1 row in set (0.00 sec)

myMemberID가 6번인 경우

SELECT * FROM mymember WHERE myMemberID = 6;
+------------+-----------------+---------+---------+------------+---------+
| myMemberID | youEmail        | youName | youPass | youBirth   | regTime |
+------------+-----------------+---------+---------+------------+---------+
|          6 | akside111@naver | akside  | 1234    | 2000-01-01 |     123 |
+------------+-----------------+---------+---------+------------+---------+
1 row in set (0.00 sec)

email 중에 naver 텍스트를 포함하는 경우

mysql> SELECT * FROM mymember WHERE youEmail LIKE '%naver%';
+------------+--------------------+---------+---------+------------+---------+
| myMemberID | youEmail           | youName | youPass | youBirth   | regTime |
+------------+--------------------+---------+---------+------------+---------+
|          1 | gkfl8809@naver     | kdong   | 1234    | 1993-12-24 |     123 |
|          2 | webstoryboy@naver  | webs    | 1234    | 1993-03-04 |     123 |
|          6 | akside111@naver    | akside  | 1234    | 2000-01-01 |     123 |
|          8 | wow2002r@naver.com | Ripia   | 1234    | 1994-11-04 |     333 |
|          9 | guswjd8694@naver   | dallae  | 1234    | 2016-05-25 |     333 |
|         10 | kws7902@naver.com  | wooseok | 1234    | 1998-08-15 |     333 |
+------------+--------------------+---------+---------+------------+---------+
6 rows in set (0.00 sec)

email 중에 webstoryboy 텍스트로 시작하는 경우

SELECT * FROM mymember WHERE youEmail LIKE 'webstoryboy%';
+------------+-------------------+---------+---------+------------+---------+
| myMemberID | youEmail          | youName | youPass | youBirth   | regTime |
+------------+-------------------+---------+---------+------------+---------+
|          2 | webstoryboy@naver | webs    | 1234    | 1993-03-04 |     123 |
+------------+-------------------+---------+---------+------------+---------+
1 row in set (0.00 sec)

email 중에 com 텍스트로 끝나는 경우

mysql> SELECT * FROM mymember WHERE youEmail LIKE '%com';
+------------+----------------------+-----------+---------+------------+---------+
| myMemberID | youEmail             | youName   | youPass | youBirth   | regTime |
+------------+----------------------+-----------+---------+------------+---------+
|          3 | younyc0413@gmail.com | youn      | 0413    | 1992-04-13 |     333 |
|          5 | seonyoung@gmail.com  | SEONYOUNG | 1234    | 1997-04-03 |     111 |
|          8 | wow2002r@naver.com   | Ripia     | 1234    | 1994-11-04 |     333 |
|         10 | kws7902@naver.com    | wooseok   | 1234    | 1998-08-15 |     333 |
+------------+----------------------+-----------+---------+------------+---------+
4 rows in set (0.00 sec)

멤버 아이디 조건 검색

mysql> SELECT * FROM mymember WHERE myMemberID >=2 AND myMemberID <=5;
+------------+----------------------+---------+---------+------------+---------+
| myMemberID | youEmail             | youName | youPass | youBirth   | regTime |
+------------+----------------------+---------+---------+------------+---------+
|          2 | webstoryboy@naver    | webs    | 1234    | 1993-03-04 |     123 |
|          3 | younyc0413@gmail.com | youn    | 0413    | 1992-04-13 |     333 |
|          4 | billiejeong08@gmail  | billie  | 1234    | 1995-08-12 |     333 |
|          5 | younyc0413@gmail.com | youn    | 0413    | 1992-04-13 |     333 |
+------------+----------------------+---------+---------+------------+---------+
4 rows in set (0.00 sec)

멤버 이름 중에 첫글자가 '김'씨 이거나 '황'씨 인 경우를 검색

mysql> SELECT * FROM mymember WHERE youName LIKE '김%' OR youName LIKE '황%';
+------------+---------------------+---------+---------+------------+---------+
| myMemberID | youEmail            | youName | youPass | youBirth   | regTime |
+------------+---------------------+---------+---------+------------+---------+
|          2 | webstoryboy@naver   | 황상연  | 1234    | 1993-03-04 |     123 |
|          5 | seonyoung@gmail.com | 김선영  | 1234    | 1997-04-03 |     111 |
|          9 | guswjd8694@naver    | 김현정  | 1234    | 2016-05-25 |     333 |
|         10 | kws7902@naver.com   | 김우석  | 1234    | 1998-08-15 |     333 |
+------------+---------------------+---------+---------+------------+---------+
4 rows in set (0.00 sec)

데이터 수정하기

UPDATE 테이블(필드명) SET 필드명 조건

회원 아이디 1번 이름 변경

mysql> UPDATE mymember SET youName = "강동재" WHERE myMemberID = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

모든 회원 비밀번호를 '1234' 변경

mysql> UPDATE mymember SET youPass = "1234";
Query OK, 1 row affected (0.00 sec)
Rows matched: 10  Changed: 1  Warnings: 0

mysql> SELECT * FROM mymember;
+------------+----------------------+---------+---------+------------+---------+
| myMemberID | youEmail             | youName | youPass | youBirth   | regTime |
+------------+----------------------+---------+---------+------------+---------+
|          1 | gkfl8809@naver       | 강동재  | 1234    | 1993-12-24 |     123 |
|          2 | webstoryboy@naver    | 황상연  | 1234    | 1993-03-04 |     123 |
|          3 | younyc0413@gmail.com | 윤여찬  | 1234    | 1992-04-13 |     333 |
|          4 | billiejeong08@gmail  | 정은지  | 1234    | 1995-08-12 |     333 |
|          5 | seonyoung@gmail.com  | 김선영  | 1234    | 1997-04-03 |     111 |
|          6 | akside111@naver      | 인재연  | 1234    | 2000-01-01 |     123 |
|          7 | HEO@gmail            | 허아라  | 1234    | 1992-03-26 |     123 |
|          8 | wow2002r@naver.com   | 최재광  | 1234    | 1994-11-04 |     333 |
|          9 | guswjd8694@naver     | 김현정  | 1234    | 2016-05-25 |     333 |
|         10 | kws7902@naver.com    | 김우석  | 1234    | 1998-08-15 |     333 |
+------------+----------------------+---------+---------+------------+---------+
10 rows in set (0.00 sec)

데이터 삭제하기

DELETE FORM 테이블명 조건 필드명

회원 아이디 3번 레코드 삭제

DELETE FROM mymember WHERE myMemberID = 3;
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM mymember;
+------------+----------------------+---------+---------+------------+---------+
| myMemberID | youEmail             | youName | youPass | youBirth   | regTime |
+------------+----------------------+---------+---------+------------+---------+
|          1 | gkfl8809@naver       | 강동재  | 1234    | 1993-12-24 |     123 |
|          2 | webstoryboy@naver    | 황상연  | 1234    | 1993-03-04 |     123 |
|          4 | billiejeong08@gmail  | 정은지  | 1234    | 1995-08-12 |     333 |
|          5 | seonyoung@gmail.com  | 김선영  | 1234    | 1997-04-03 |     111 |
|          6 | akside111@naver      | 인재연  | 1234    | 2000-01-01 |     123 |
|          7 | HEO@gmail            | 허아라  | 1234    | 1992-03-26 |     123 |
|          8 | wow2002r@naver.com   | 최재광  | 1234    | 1994-11-04 |     333 |
|          9 | guswjd8694@naver     | 김현정  | 1234    | 2016-05-25 |     333 |
|         10 | kws7902@naver.com    | 김우석  | 1234    | 1998-08-15 |     333 |
+------------+----------------------+---------+---------+------------+---------+
9 rows in set (0.00 sec)

회원 아이디 4,5,6번 레코드 삭제

mysql> DELETE FROM mymember WHERE myMemberID IN(4,5,6);
Query OK, 3 rows affected (0.00 sec)

mysql> SELECT * FROM mymember;
+------------+--------------------+---------+---------+------------+---------+
| myMemberID | youEmail           | youName | youPass | youBirth   | regTime |
+------------+--------------------+---------+---------+------------+---------+
|          1 | gkfl8809@naver     | 강동재  | 1234    | 1993-12-24 |     123 |
|          2 | webstoryboy@naver  | 황상연  | 1234    | 1993-03-04 |     123 |
|          7 | HEO@gmail          | 허아라  | 1234    | 1992-03-26 |     123 |
|          8 | wow2002r@naver.com | 최재광  | 1234    | 1994-11-04 |     333 |
|          9 | guswjd8694@naver   | 김현정  | 1234    | 2016-05-25 |     333 |
|         10 | kws7902@naver.com  | 김우석  | 1234    | 1998-08-15 |     333 |
+------------+--------------------+---------+---------+------------+---------+
6 rows in set (0.00 sec)
mysql> CREATE TABLE myMember(
    ->         myMemberID int(10) unsigned auto_increment,
    ->         youID varchar(15) not null,
    ->         youName varchar(10) not null,
    ->         youPass varchar(30) not null,
    ->         youEmail varchar(30) not null,
    ->         regTime int() not null,
    ->         PRIMARY KEY (myMemberID)
    ->     ) charset=utf8;
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE myReview(
    ->         myReviewID int(10) unsigned auto_increment,
    ->         myMemberID int(10) unsigned,
    ->         yoiCont tinytext not null,
    ->         regTime int(30) not null,
    ->         PRIMARY KEY (myReviewID)
    ->     ) charset=utf8;
Query OK, 0 rows affected (0.02 sec)

mysql> show tables;
+------------------+
| Tables_in_test01 |
+------------------+
| mymember         |
| myreview         |
+------------------+
2 rows in set (0.00 sec)

mysql> desc mymember;
+------------+------------------+------+-----+---------+----------------+
| Field      | Type             | Null | Key | Default | Extra          |
+------------+------------------+------+-----+---------+----------------+
| myMemberID | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| youID      | varchar(15)      | NO   |     | NULL    |                |
| youName    | varchar(10)      | NO   |     | NULL    |                |
| youPass    | varchar(30)      | NO   |     | NULL    |                |
| youEmail   | varchar(30)      | NO   |     | NULL    |                |
| regTime    | int(30)          | NO   |     | NULL    |                |
+------------+------------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

mysql> desc myreview;
+------------+------------------+------+-----+---------+----------------+
| Field      | Type             | Null | Key | Default | Extra          |
+------------+------------------+------+-----+---------+----------------+
| myReviewID | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| myMemberID | int(10) unsigned | YES  |     | NULL    |                |
| youCont    | tinytext         | NO   |     | NULL    |                |
| regTime    | int(30)          | NO   |     | NULL    |                |
+------------+------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

INSERT INTO myMember(youID, youName, youPass, youEmail, regTime) VALUES('KDONG','강동재','1234','gkfl8809@naver.com','1224');
INSERT INTO myMember(youID, youName, youPass, youEmail, regTime) VALUES('webs','황상연','1234','webstoryboy@naver.com','1224');
INSERT INTO myMember(youID, youName, youPass, youEmail, regTime) VALUES('water','꼬부기','1da234','water12@naver.com','1224');
INSERT INTO myMember(youID, youName, youPass, youEmail, regTime) VALUES('fire','파이리','11hht34','fire34@naver.com','1224');
INSERT INTO myMember(youID, youName, youPass, youEmail, regTime) VALUES('aespa','에스파','11ldaw854','aespapower@naver.com','1224');

INSERT INTO myReview(myMemberID, youCont, regTime) VALUES(3,'이 가방 너무 좋네요!!','1224');
INSERT INTO myReview(myMemberID, youCont, regTime) VALUES(3,'이 사기에요!! 제발 사지마세요','1224');
INSERT INTO myReview(myMemberID, youCont, regTime) VALUES(1,'댓글다 알바생임?','1224');
INSERT INTO myReview(myMemberID, youCont, regTime) VALUES(1,'이거 추천 알바아님 지인임!','1224');

mysql> SELECT * FROM myMember;
+------------+-------+---------+-----------+-----------------------+---------+
| myMemberID | youID | youName | youPass   | youEmail              | regTime |
+------------+-------+---------+-----------+-----------------------+---------+
|          1 | KDONG | 강동재  | 1234      | gkfl8809@naver.com    |    1224 |
|          2 | webs  | 황상연  | 1234      | webstoryboy@naver.com |    1224 |
|          3 | water | 꼬부기  | 1da234    | water12@naver.com     |    1224 |
|          4 | fire  | 파이리  | 11hht34   | fire34@naver.com      |    1224 |
|          5 | aespa | 에스파  | 11ldaw854 | aespapower@naver.com  |    1224 |
+------------+-------+---------+-----------+-----------------------+---------+
5 rows in set (0.00 sec)

mysql> SELECT * FROM myReview;
+------------+------------+-------------------------------+---------+
| myReviewID | myMemberID | youCont                       | regTime |
+------------+------------+-------------------------------+---------+
|          1 |          3 | 이 가방 너무 좋네요!!         |    1224 |
|          2 |          3 | 이 사기에요!! 제발 사지마세요 |    1224 |
|          3 |          1 | 댓글다 알바생임?              |    1224 |
|          4 |          1 | 이거 추천 알바아님 지인임!    |    1224 |
+------------+------------+-------------------------------+---------+
4 rows in set (0.00 sec)

Join문 사용하기

SELECT 필드명 FROM 테이블명 앨리어스 JOIN 연결할 테이블명 앨리어스 ON(조건문)

두개의 테이블 JOIN 하기

mysql> SELECT m.youName, r.youCont, r.regTime FROM myMember m JOIN myReview r ON (m.myMemberID = r.myMemberID);
+---------+-------------------------------+---------+
| youName | youCont                       | regTime |
+---------+-------------------------------+---------+
| 꼬부기  | 이 가방 너무 좋네요!!         |    1224 |
| 꼬부기  | 이 사기에요!! 제발 사지마세요 |    1224 |
| 강동재  | 댓글다 알바생임?              |    1224 |
| 강동재  | 이거 추천 알바아님 지인임!    |    1224 |
+---------+-------------------------------+---------+
4 rows in set (0.00 sec)

필드명을 변경하여 표시하는 방법

mysql> SELECT m.youName, r.youCont, r.regTime AS reviewTime FROM myMember m JOIN myReview r ON (m.myMemberID = r.myMemberID);
+---------+-------------------------------+------------+
| youName | youCont                       | reviewTime |
+---------+-------------------------------+------------+
| 꼬부기  | 이 가방 너무 좋네요!!         |       1224 |
| 꼬부기  | 이 사기에요!! 제발 사지마세요 |       1224 |
| 강동재  | 댓글다 알바생임?              |       1224 |
| 강동재  | 이거 추천 알바아님 지인임!    |       1224 |
+---------+-------------------------------+------------+
4 rows in set (0.00 sec)

필드 내용이 없는 경우 표시하는 방법

mysql> SELECT m.youName, r.youCont, r.regTime FROM myMember m LEFT JOIN myReview r ON (m.myMemberID = r.myReviewID);
+---------+-------------------------------+---------+
| youName | youCont                       | regTime |
+---------+-------------------------------+---------+
| 강동재  | 이 가방 너무 좋네요!!         |    1224 |
| 황상연  | 이 사기에요!! 제발 사지마세요 |    1224 |
| 꼬부기  | 댓글다 알바생임?              |    1224 |
| 파이리  | 이거 추천 알바아님 지인임!    |    1224 |
| 에스파  | NULL                          |    NULL |
+---------+-------------------------------+---------+
5 rows in set (0.00 sec)
SELECT 필드명 FROM 테이블명 앨리어스 JOIN 연결할 테이블명 엘리어스 ON(조건문);
CREATE TABLE myRecode (
    recodeID int(10) unsigned auto_increment,
    memberID int(10) unsigned,
    javascript tinyint NOT NULL,
    html tinyint NOT NULL,
    css tinyint NOT NULL,
    mysql tinyint NOT NULL,
    react tinyint NOT NULL,
    PRIMARY KEY (recodeID)
) charset=utf8;

INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(1, 50, 30, 10, 30, 10);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(2, 60, 35, 20, 10, 20);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(3, 55, 46, 50, 30, 31);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(4, 84, 30, 70, 30, 50);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(5, 56, 44, 90, 20, 40);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(6, 80, 30, 50, 90, 50);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(7, 40, 95, 50, 50, 60);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(8, 49, 30, 20, 80, 100);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(9, 55, 70, 40, 30, 85);
INSERT INTO myRecode(memberID, javascript, html, css, mysql, react) VALUES(10, 55, 30, 40, 30, 20);

집계함수의 종류

SELECT count(javascript) from myrecode;
SELECT sum(javascript) from myrecode;
SELECT avg(javascript) from myrecode;
SELECT max(javascript) from myrecode;
SELECT min(javascript) from myrecode;

그룹별 집계

GROUP BY

SELECT 필드명 FROM 테이블명 GROUP BY 필드명
SELECT memberID avg(javascript) from myrecode WHERE memberID IN(1,2,3,4) GROUP BY memberID;