Filtering in SQL: containing exact string

PHOTO EMBED

Fri Sep 29 2023 17:53:14 GMT+0000 (Coordinated Universal Time)

Saved by @jaez #mysql

#Find patients with Type 1 Diabetes using the prefix 'DIAB1'

+--------------+---------+
| Column Name  | Type    |
+--------------+---------+
| patient_id   | int     |
| patient_name | varchar |
| conditions   | varchar |
+--------------+---------+ 

  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      |
+------------+--------------+--------------+
SELECT *
FROM Patients
WHERE conditions LIKE 'DIAB1%' 
or conditions LIKE '% DIAB1%';
content_copyCOPY

https://leetcode.com/problems/patients-with-a-condition/description/?envType=study-plan-v2&envId=30-days-of-pandas&lang=pythondata