Notice
Recent Posts
Recent Comments
05-17 09:12
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Byeol Lo

Database Management - SQL Operators 본문

BackEnd/Database Management

Database Management - SQL Operators

알 수 없는 사용자 2023. 4. 1. 16:54

 SQL의 연산자들을 살펴보자. 모든 연산자들은 다음과 같이 있다.

https://dev.mysql.com/doc/refman/8.0/en/non-typed-operators.html

 

MySQL :: MySQL 8.0 Reference Manual :: 12.4 Operators

MySQL 8.0 Reference Manual  /  Functions and Operators  /  Operators Table 12.3 Operators Name Description Introduced Deprecated & Bitwise AND > Greater than operator >> Right shift >= Greater than or equal operator < Less than operator <>, != Not eq

dev.mysql.com

 

이름 설명
산술연산자  +, -, *, /, % 등이 있다.
비교연산자 =, <, >, =>, =<, <>(!=), <=>(NULL-safe equal to operator)
논리연산자 AND(&&), OR(||), NOT(!), XOR(^)
IS IS, IS NOT이 있고, 해당 값이 같은지 비교해준다.
IS NULL IS NULL, IS NOT NULL이 있다. NULL 인지 아닌지 비교해준다.
LIKE 해당 패턴을 가지고 있는지 연산한다.
'rainbow' LIKE '%nbo_'를 하면 %는 아무 문자열을 뜻하고, _는 문자 하나를 뜻한다. NOT LIKE 또한 있다.
REGEXP 정규표현식을 통한 비교를 하게 된다.

MySQL은 Regular Expressions/POSIX-Extended Regular Expressions 을 사용한다.
https://en.wikibooks.org/wiki/Regular_Expressions/POSIX-Extended_Regular_Expressions
BETWEEN BETWEEN value1 AND value2로 사용되고, value1 이상 value2 이하의 값인지 보게 된다. (양측 값이 포함됨)
IN IN (value1, value2, ...) 형태로 사용된다. 수학의 원소 이냐 아니냐와 동일하다. 
CASE CASE expression
    WHEN value1 THEN result1
    WHEN value2 THEN result2
    ...
    ELSE result
END
의 형태 또는
CASE
    WHEN condition1 THEN result1
    WHEN condition2 THEN result2
    ...
    ELSE result
END
로 사용된다.

 

정규표현식

 

Comments