테이블과 결과
Input:
Patients table:
+------------+--------------+--------------+
| patient_id | patient_name | conditions |
+------------+--------------+--------------+
| 1 | Daniel | YFEV COUGH |
| 2 | Alice | |
| 3 | Bob | DIAB100 MYOP |
| 4 | George | ACNE DIAB100 |
| 5 | Alain | DIAB201 |
+------------+--------------+--------------+
Output:
+------------+--------------+--------------+
| patient_id | patient_name | conditions |
+------------+--------------+--------------+
| 3 | Bob | DIAB100 MYOP |
| 4 | George | ACNE DIAB100 |
+------------+--------------+--------------+
Explanation: Bob and George both have a condition that starts with DIAB1.
문제
- DIAB1으로 시작하는 conditions를 가진 환자들을 뽑으시오
답
SELECT
p.patient_id
,p.patient_name
,p.conditions
FROM Patients p
WHERE REGEXP_LIKE(p.conditions, ' +DIAB1|^DIAB1')
;