Filtering with WHERE
Filtering rows with WHERE
So far every query returned all the rows. Add a WHERE clause to keep only the rows that match a condition:
Only rows where the condition is true are returned.
WHERE를 이용한 행 필터링
지금까지 모든 쿼리는 모든 행을 반환했습니다. 조건에 맞는 행만 남기려면 WHERE 구문을 추가하세요:
SELECT name, score FROM student WHERE score >= 80;
조건이 참인 행만 반환됩니다.
Comparison operators
You can compare with:
=equal to<>not equal to<less than,>greater than<=at most,>=at least
Numbers are written plainly (80). Text must go in single quotes ('11B'):
비교 연산자
다음과 같이 비교할 수 있습니다:
=등가(=)<>부등가(!=)<는 '보다 작음',>는 '보다 큼'<=는 '최대',>=는 '최소'
숫자는 그대로 표기합니다(80). 텍스트는 단일 인용부호로 감싸야 합니다('11B'):
SELECT name FROM student WHERE form = '11B';
Common mistakes
- Text values go in single quotes:
WHERE name = 'Ann'. WHEREcomes afterFROM.
흔한 실수
- 텍스트 값은 단일 인용부호를 사용합니다:
WHERE name = 'Ann'. WHERE은FROM다음에 옵니다.
WHERE filters rows
WHERE keeps only the rows whose condition is true.
Show the name and score of every student who scored 80 or more.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Show the name of every student in form 11B. (Text goes in single quotes.)
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.