SQL

SQL 기초 다지기

뇌장하드 2021. 12. 29. 12:55

sql기초 배우기 좋은 사이트 

https://www.w3schools.com/sql/default.asp

 

SQL Tutorial

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

https://sqlzoo.net/wiki/SQL_Tutorial

 

SQLZOO

 

sqlzoo.net

 

SQL SELECT 문 

select문은 데이터베이스에서 데이터를 선택하는데 사용합니다.

SELECT column1, column2, ...
FROM table_name;

 

SQL SELECT DISTINCT 문 

중복을 제외하여 데이터를 보여준다.

SELECT DISTINCT column1, column2, ...
FROM table_name;

추가 응용 

COUNT를 사용하면 중복 제외한 컬럼의 갯수를 반환해준다.

SELECT COUNT(DISTINCT column1)
FROM table_name;

SQL AS

SELECT한 결과의 별칭을 주기 위해서 AS를 사용한다.

SELECT name AS 이름, age AS 나이
FROM people
WHERE name = "철수";

SQL WHERE 

WHERE문은 조건을 걸때 사용한다.

 

SQL NOT

도시 중에서 베를린이 아닌것을 골라라 Customers에서

SELECT * FROM Customers
Where Not City='Berlin'

SQL Where (or,and)

or  아무거나 조건 적용  and 무조건 다 조건 적용