Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

mysql where a column does not contain regular expression with value from another column

I have the below table and I need to find all rows where the resource_path does not contain the code in the string.

id | code | resource_path
1   abc01    /this/is/path/to/resource/abc01/xyz.jpg
2   abc02    /this/is/path/to/resource/abc02/xyz.png
3   abc02    /this/is/path/to/resource/xyz.png 

I have tried the following query

SELECT * FROM aTable WHERE resource NOT IN (select code from aTable) ORDER BY id DESC LIMIT 10;

but this returns everything.
Thanks in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SELECT * FROM aTable where resource_path not like concat('%', code, '%');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading