REGEXP one liner (MySQL)
Going through different solutions, I didn\'t see anyone use a regular expression with a boundary. So, I decided to post one.\n\nSELECT * FROM patients WHERE con
Going through different solutions, I didn\'t see anyone use a regular expression with a boundary. So, I decided to post one.\n```\nSELECT * FROM patients WHERE conditions REGEXP \'\\\\bDIAB1\'\n```\n\nThe expression `conditions REGEXP \'\\\\bDIAB1\'` is actually the same as `conditions LIKE \'% DIAB1%\' OR\nconditions LIKE \'DIAB1%\';`, but it is obviously shorter. \uD83D\uDE09\n\nThe reason they are the same is that `\\b` matches either a non-word character (in our case, a space) or the position before the first character in the string. Also, you need to escape a backslash with another backslash, like so: `\\\\b`. Otherwise, the regular expression won\'t evaluate.\n\nP.S. `\\b` also matches the position after the last character, but it doesn\'t matter in the context of this problem.\n
['MySQL']