2 Solutions (LIKE and REGEXP) || MySQL simple solution || 78.67% Faster
Approach\nThere are 2 solutions provided, 1 is commented out and the other below that. \n1. The one in comment is simple, the query selects all the columns wher
# Approach\nThere are 2 solutions provided, 1 is commented out and the other below that. \n1. The one in comment is simple, the query selects all the columns where either the condition starts with \'DIAB1%\' and can have any character after that OR it has a space before DIAB1 i.e. \'% DIAB1%\' indicating that it is a new word to avoid cases like \'SADIAB100\'\n\n2. The second solution is an abbreviation of first using **REGEXP** expression where \'\\b\' is a word boundary anchor in regular expressions.It represents a position between a word character (like letters, digits, and underscores) and a non-word character (like spaces, punctuation, or the start/end of the string). \n**Here we use \'\\\\\\b\' as the first backlash is used to escape the \'\\b\'**\n\n# Code\n```\n# Write your MySQL query statement below\n-- SELECT * FROM Patients WHERE conditions LIKE "% DIAB1%" OR conditions LIKE "DIAB1%";\nSELECT * FROM Patients WHERE conditions REGEXP "\\\\bDIAB1";\n```
['Database', 'MySQL']