Patients With a Condition
Task: Write a solution to find the patient_id, patient_name, and conditions of the patients who have Type I Diabetes. Type I Diabetes always starts with DIAB1 prefix.
Table: Patients
| Column Name | Type |
|---|---|
| patient_id | INT |
| patient_name | varchar(30) |
| conditions | varchar(100) |
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 |
View Reference Solution & Explanation ▼
This solution uses pattern matching to filter string values to find the required output.
SELECT patient_id, patient_name, conditions FROM Patients WHERE conditions LIKE 'DIAB1%' OR conditions LIKE '% DIAB1%';