SELECT 取得資料
原始`student` TABLE :
SELECT * FROM `student`;
SELECT `name` FROM `student`;
SELECT `name`,`major` FROM `student`;
ASC (預設)由小到大
SELECT *
FROM `student`
ORDER BY `score`;
DESC 由大到小
SELECT *
FROM `student`
ORDER BY `score` DESC;
先根據score屬性做排序,如果score屬性的值一樣,接下來會根據student_id排序
SELECT *
FROM `student`
ORDER BY `score`, `student_id`;
回傳前3筆資料
SELECT *
FROM `student`
LIMIT 3;
SELECT *
FROM `student`
ORDER BY `score`
LIMIT 4;
SELECT *
FROM `student`
WHERE `major` = '英語' AND `student_id` = 1;
SELECT *
FROM `student`
WHERE `major` IN ('歷史','英語','生物');
# 等於下列
# WHERE `major`='歷史' OR `major` = '英語' OR `major` = '生物';