ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • like / ilike / as
    postgresql 2023. 7. 27. 18:38

    like

    % 대신에 _ 를 사용하면 한글자 매칭 조건을 줄 수 있다

    select last_name from actor
    where last_name like '_ah%'

    위의 실행 결과로 Wahs, Hah 등이 결과로 나올 수 있다.

    ilike

    대소문자 구분없이 매칭함

    select last_name  from actor
    where last_name ilike 'j%'

    위의 실행 결과로 Jane, Jhon, july 등이 결과로 나올 수 있다.

     

    as

    alias 로 사용되는 as 는 SQL 의 마지막에 실행된다. 따라서 select 구문에 이어서만 사용할 수 있다. where 나 on 등에서는 사용할 수 없다.

    • 허용 되는 경우 예
    select customer_id, sum(amount) as total from payment
    group by customer_id 
    having sum(amount) >= 30

     

    • 허용 되지 않는 경우 (에러 발생) 예
    select customer_id, sum(amount) as total from payment
    group by customer_id 
    having total >= 30

     

    'postgresql' 카테고리의 다른 글

    VIEW  (0) 2023.07.28
    CHECK constraint (when create table)  (0) 2023.07.28
    Timestamp and Extract  (0) 2023.07.28
    외부 데이터 import 하기  (0) 2023.07.27
    PostgreSQL 소개  (0) 2023.07.27

    댓글

Designed by Tistory.