본문 바로가기
AI월드/⚙️AI BOOTCAMP_Section 3

SQL 명령어 정리_Day43(2)

by khalidpark 2021. 3. 8.

많이 쓰이는 명령어

SELECT : 데이터셋에 포함될 특성 ( SELECT DISTINCT 유니크 값, Select all the different values)
FROM : 테이블 이름
WHERE : 필터 역할 (= , > , < , => , =< , <>특정값제외 , LIKE (%k%) , IN , IS NULL , NOT NULL )
ORDER BY : 정렬 (기본값 오름차순) (DESC 내림차순)LIMIT : 돌려받는 데이터 결과 갯수
INNER JOIN (또는 JOIN) (JOIN ~~~ ON ~~)
OUTER JOIN (LEFT OUTER JOIN , RIGHT OUTER JOIN)
GROUP BY

 

저 아래 있는 사이트들에서 직접 실습해보면서 해당 명령어에 익숙해져보자


연습사이트에서 추가한 내용

INSERT INTO (A,B,C) VALUES (A',B',C')

UPDATE customers SET city ='oslo'

DELETE FROM customers WHERE country = 'norway'

SQL FUNCTION
- SELECT MIN
- SELECT MAX
- SELECT COUNT(*) FROM Products WHERE price=18
- SELECT AVG
- SELECT SUM

WILDCARD
- SELECT * FROM Customers WHERE City LIKE '_a%' 2번째 문자가 a인걸 고를때
- SELECT * FROM Customers WHERE City LIKE '[acs]%' 1번째 문자가 a 또는 c 또는 s로 시작할때
- SELECT * FROM Customers WHERE City LIKE '[a-s]%' 1번째 문자가 a 끝문자가 s
- SELECT * FROM Customers WHERE City LIKE '[^acs]%' 1번째 문자가 a 또는 c 또는 s가 아닐때

SELECT * FROM Customers WHERE Country IN ('Norway' ,'France')

BETWEEN
SELECT * FROM Products WHERE price BETWEEN 10 and 20

SQL JOINS

 

SQL 연습하기 좋은 사이트

www.w3schools.com/SQl/sql_exercises.asp

 

SQL Exercises

SQL Exercises You can test your SQL skills with W3Schools' Exercises. Exercises We have gathered a variety of SQL exercises (with answers) for each SQL Chapter. Try to solve an exercise by filling in the missing parts of a code. If your stuck, hit the "Sho

www.w3schools.com

sqlbolt.com/lesson/select_queries_with_constraints

 

SQLBolt - Learn SQL - SQL Lesson 2: Queries with constraints (Pt. 1)

SQL Lesson 2: Queries with constraints (Pt. 1) Now we know how to select for specific columns of data from a table, but if you had a table with a hundred million rows of data, reading through all the rows would be inefficient and perhaps even impossible. I

sqlbolt.com

이미지 출처 : velog.io/@ghd64845/DB-SQL%EC%97%90-%EB%8C%80%ED%95%B4-%EC%95%8C%EC%95%84%EB%B3%B4%EC%9E%90

 

[DB] SQL에 대해 알아보자!

Structured Query Language의 약자로 데이터 베이스가 이해할 수 있는 구조화된 질의 언어입니다.쉽게 말해서 우리가 영어를 공부 할 때 문법에 맞게 말을 해야 상대방이 알아 듣는 것 처럼 SQL도 문법에

velog.io

728x90

댓글