3 easy MySQL solution ✅ || Pandas 1-liner✅ || Beginner-friendly ✅
Intuition\n Describe your first thoughts on how to solve this problem. \n#### Solution 1\nIn solution 1, we use LIKE operator to match the substring that we nee
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n#### Solution 1\nIn solution 1, we use **LIKE** operator to match the substring that we need to find. Here, we use `\'% DIAB1%\'` and `\'DIAB1%\'` because the question states that** DIAB1 will always be in the prefix so there can be a space before DIAB1 or DIAB1 is in the start of the condition**.\n\n#### Solution 2\nIn solution 2, we use **regular expression** `REGEXP \'\\\\bDIAB1\' ` where **\\b** matches either a non-word character (in our case, a space) or the position before the first character in the string.\n\n#### Solution 3\nIn solution 3, we use **regular expression** `REGEXP \'^DIAB1|[:space:]DIAB1\'` which is similar to logic of solution 1. **Either our expression starts with DIAB1 or there is a space before DIAB1**. \n\n# Code\n```\n# Solution 1\nSELECT *\nFROM Patients\nWHERE conditions LIKE \'% DIAB1%\' OR conditions LIKE \'DIAB1%\';\n\n# Soution 2 \nSELECT * \nFROM patients \nWHERE conditions REGEXP \'\\\\bDIAB1\' \n\n# Solution 3\nSELECT *\nFROM Patients\nWHERE conditions REGEXP \'^DIAB1|[:space:]DIAB1\'\n```\n```\ndef find_patients(patients: pd.DataFrame) -> pd.DataFrame:\n    return patients[patients[\'conditions\'].str.contains(r\'(^DIAB1)|( DIAB1)\')]\n```
['MySQL', 'Pandas']