본문 바로가기
취준/코팅 테스트

[LeetCode] - 1527. Patients With a Condition

by 소복소복뚜벅뚜벅 2024. 3. 26.

문제 

 

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.

Return the result table in any order.

The result format is in the following example.

 

 

1-1 문제풀이  

SELECT * 
FROM Patients 
WHERE conditions REGEXP '\\bDIAB1'

 

 

 

1-2 문제 풀이 

SELECT patient_id, patient_name, conditions 
FROM Patients 
WHERE conditions LIKE 'DIAB1%' 
  AND coditions LIKE '% DIAB1%'

 

 

오답이유 

1. 'SADIAB100'의 경우를 어떻게 처리 해야 할지 생각을 못함. 

2. 정규 표현식에서 \b의기능이 무엇인지 알지 못했음.

\b : 단어구분자.