Help with a not match - Mailing list pgsql-sql

From Campbell, Lance
Subject Help with a not match
Date
Msg-id E48BCA4C-5847-4634-8E9D-A91C9C4E40E6@illinois.edu
Whole thread Raw
Responses Re: Help with a not match  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql

Use case:

I have a table I will call “tableA”.  It has two columns.  One column is an “id” that is an integer primary key.  The second field is a text field called “content”.

 

In the “content” field there may or may not be this substring “/files/{id}/” .  Note that {id} represents the field id for that record.  I want to find any rows where content contains “/files/###/” where the ### does not match the id for the row.  Also note that the id could be 1 to five digits.  Also there could be good and bad substrings in the content field.

 

Example where a row is fine:

Id=123

Content=”abc”

 

Id=345

Content=”abc files/345/ abc files/345/”

 

Example where a rows are not good:

Id=123

Content=”abc files/456/”

 

Id=123

Content=”abc files/123/ abc files/456/”

 

 

Could you please help me with the proper way to write this SQL statement?

 

Select id from tableA where content like …

 

 

Thanks,

 

Lance

pgsql-sql by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: Regular Expressions
Next
From: "David G. Johnston"
Date:
Subject: Re: Help with a not match