1527. Patients With a Condition
Problem Statement
Find patient_id, patient_name, and conditions of the patients who have Type I Diabetes, i.e. a condition code that starts with 'DIAB1' (as a standalone code, not a substring elsewhere). Return the result table in any order.
Table Schema
Table: Patients
+---------------+---------+
| patient_id | int |
| patient_name | varchar |
| conditions | varchar |
+---------------+---------+
patient_id is the primary key. conditions contains 0 or more space-separated codes.
Examples
Example 1
Input Table:
Patients table:
+------------+--------------+--------------+
| patient_id | patient_name | conditions |
+------------+--------------+--------------+
| 1 | Daniel | YFEV COUGH |
| 2 | Alice | DIAB100 MYOP |
| 3 | Bob | ACNE DIAB100 |
+------------+--------------+--------------+
Expected Output:
+------------+--------------+--------------+
| patient_id | patient_name | conditions |
+------------+--------------+--------------+
| 2 | Alice | DIAB100 MYOP |
| 3 | Bob | ACNE DIAB100 |
+------------+--------------+--------------+
SQL Solution
SELECT *
FROM Patients
WHERE conditions LIKE 'DIAB1%'
OR conditions LIKE '% DIAB1%';
Problem Info
DifficultyEASY
Topics
likestring-matching
Reference Links