=, <>
SUM(price), AVG(price), COUNT(*), MAX(price), MIN(price)
round(price, 2)
select price as p
select distinct price
order by price asc
order by price desc
우선순위에 따라 ,로 배치
SELECT * FROM tb_product WHERE product_name LIKE CONCAT('%','a','%');
https://velog.io/@syh0397/SQL-날짜와-시간-문자열-다루기
2. 예문)
1.DATE_FORMAT(now(), '%Y-%m-%d') // 2011-06-14
2.DATE_FORMAT(now(), '%Y-%M-%D') // 2011-June-14th
3.DATE_FORMAT(now(), '%H:%i:%s') // 22:26:11 ( 24시간 표현 )
4.DATE_FORMAT(now(), '%h:%i:%s') // 10:26:11 ( 12시간 표현 )
합집합 - UNION
# NULL 값 주는 경우
select id, NULL date
from T1
union
select id, data
from T2;
차집합 - EXCEPT
교집합 - INTERSECT
SELECT *
FROM CUSTOMER, ORDERS;
또는
SELECT 조회할컬럼
FROM 테이블1
JOIN 테이블2
또는
SELECT 조회할컬럼
FROM 테이블1
CROSS JOIN 테이블2
SELECT Sales.*, Countries.Country
FROM Sales
JOIN Countries
ON Sales.CountryID = Countries.ID
[FULL OUTER JOIN]
SELECT *
FROM instructor
FULL OUTER JOIN teaches
ON instructor.id = teaches.id
[LEFT OUTER JOIN]
SELECT *
FROM instructor
LEFT OUTER JOIN teaches
ON instructor.id = teaches.id
[RIGHT OUTER JOIN]
SELECT *
FROM instructor
RIGHT OUTER JOIN teaches
ON instructor.id = teaches.id
IN, > ALL, < SOME, EXISTS
select top 2 price
from products;
<예시>
SELECT userID, addr, mDate
FROM userTb1
WHERE addr LIKE '%산'