Check this out please, thsi is only selecting the rows that has both your strings.
The reason here that your original regex didn't work:
Because MySQL uses the C escape syntax in strings (for example, “\n” to represent the newline character), you must double any “\” that you use in your REGEXP strings.
Query:
SELECT * FROM vendor
WHERE (vname REGEXP '~20\\|2~'
AND vname REGEXP '~14\\|1~')
;
Query: Notice that I have used a different table/sample data than yours. But copied your data row and changed a bit to trigger the correct regex.
Sample Data:
| VID | VNAME |
------------------------------------------------------------
| 1 | ~20|2~14|1~15|1~16|1~1|1397|1|0:0:0:0||~17|1~18|1~ |
| 2 | ~20|2~14|1397|1|0:0:0:0||~17|1~18|1~ |
| 3 | ~20|2~14|1~15|1~16|1~1|1397|1|0:0:0:0||~17|1~18|1~ |
| 4 | ~20|2~1|1~16|1~1|1397|1|0:0:0:0||~17|1~18|1~ |
Query:
SELECT * FROM vendor
WHERE (vname REGEXP '~20\[|]2~'
AND vname REGEXP '~14\[|]1~')
;
Results:
| VID | VNAME |
------------------------------------------------------------
| 1 | ~20|2~14|1~15|1~16|1~1|1397|1|0:0:0:0||~17|1~18|1~ |
| 3 | ~20|2~14|1~15|1~16|1~1|1397|1|0:0:0:0||~17|1~18|1~ |