개키우는개발자 : )

PostgreSQL 실습문제2 본문

PostgreSQL/데이터 조회와 필터링

PostgreSQL 실습문제2

DOGvelopers 2019. 10. 29. 20:57
반응형

문제

고객에게 단체 이메일을 전송 하고자 한다. CUSTOMER 테이블에서 고객의 EMAIL 주소를 추출하고, 이메일 형식에 맞지 않는 이메일 주소는 제외시켜라. ( '@'가 존재해야 하고 '@'로 시작하지 말아야 하고 '@'로 끝나지 말아야 한다.)

 

1. @로 시작하지 않기

select email from customer
where email not like '@%'

결과1

2. @로 끝나지 않기

select email from customer
where email not like '@%'
and email not like '%@'

결과2

3. @를 포함하기

select email from customer
where email not like '@%'
and email not like '%@'
and email like '%@%';

결과3

 

반응형
Comments