SELECT FROM [table] WHERE [value]
select
symbol, company_name
from nasdaq_company
3 검색
2 symbol과 company_name을
1 nasdaq_company 테이블의
결과

select
*
from nasdaq_company
where symbol = 'AAPL' or symbol = 'MSFT' or symbol = 'TSLA'
4 검색
2 모든 데이터에서
1 nasdaq_company 테이블의
3 심볼이 APPL 또는 MSFT 또는 TSLA 인것들을 (조건)
select
*
from nasdaq_company
where symbol in ('AAPL', 'MSFT', 'TSLA')

WHERE Like '%value%'
%조건% : 앞뒤 어느 문자열이 와도 상관없이 조건문에 포함된 데이터 반환
select * from nasdaq_company where symbol like '%A%' -- 어떤 문자열 + A + 어떤 문자열

select * from nasdaq_company where symbol like 'A%' -- A + 어떤 문자열

select * from nasdaq_company where symbol like 'AA%' -- AA + 어떤 문자열

select * from nasdaq_company where symbol like 'A_' -- A + 어떤 문자

select * from nasdaq_company where symbol like 'A_C%' -- A + 어떤 문자 + C

select * from nasdaq_company where symbol like 'AA[c,p]%' -- AA + c 또는 p를 포함하는 문자 + 어떤 문자열

select * from nasdaq_company where symbol like 'AA[^L]%' -- AA + L을 포함하지 않는 문자열

select * from nasdaq_company where symbol like 'A%L_' -- A + 어떤 문자열 + L + 어떤 문자

-- 테이블 생성
WITH CTE (col_1) AS (
SELECT 'A%BC' UNION ALL
SELECT 'A_BC' UNION ALL
SELECT 'ABC'
)
--SELECT * FROM CTE
--SELECT * FROM CTE WHERE col_1 LIKE '%%%' -- 어떤 문자열이 와도 상관 X
SELECT * FROM CTE WHERE col_1 LIKE '%#%%' ESCAPE '#' -- # 빼고 실행
생성한 테이블

출력 결과

ORDER BY < col >...< col n >
select * from nasdaq_company
ORDER BY symbol desc -- 내림차순 정렬

select * from nasdaq_company
ORDER BY ipo_year desc, symbol ASC
-- ipo_year 에 대해 내림차순, 동일한 값일 내에서 symbol 오름차순으로 정렬

문제 풀이
select * from nasdaq_company
select * from nasdaq_company WHERE symbol='MSFT'
select * from nasdaq_company WHERE company_name like '%apple%'
select * from nasdaq_company WHERE symbol like'AA%[L,Q]%'
select * from nasdaq_company WHERE last_sales <= 1 and symbol not like '%^%'
select * from nasdaq_company WHERE symbol not like '%[-,^,=]%'
and last_sales <> 0 ORDER BY last_sales DESC
select * from nasdaq_company WHERE last_sales BETWEEN 10 AND 20 AND volume>=1000000000
AND company_name not like '%A%' AND ipo_year >= '2019'
ORDER BY last_sales DESC, ipo_year ASC
SELECT < col > FROM [table1] as T1 JOIN [table2] as T2 on T1.col1 = T2.col1
WHERE < col > = [value] ORDER BY [col]
(ON :조인 조건, WHERE : 필터 조건)
※ 데이터 출처 : Do it! SQL입문 (이지스퍼블리싱)