0

Let's say I have a list of person names and a list of social media URL's (that might or might not contain a portion of the person names).

I'm trying to see if the full name is not contained in the list of URL's I have. I don't think a "not like" would work here (because the URL has plenty of other characters to throw back a result), but I can't think of any other way to address this. Any tips? The closest I could find was from this:

Matching partial words in two different columns

But I'm unsure if that applies here.

Community
  • 1
  • 1
kshankar
  • 43
  • 1
  • 1
  • 4

1 Answers1

0

Just use SELECT * FROM yourtable WHERE url LIKE '%name%' % means any characters even whitespace. Then just check if it returned any rows.

From mysql doc:

% matches any number of characters, even zero characters.

mysql> SELECT 'David!' LIKE 'David_';
-> 1
mysql> SELECT 'David!' LIKE '%D%v%';
-> 1

So let's say these are your url's in your list:
website.com/peterjohnson
website.com/jackmiller
website.com/robertjenkins

Then if you would do:

SELECT * FROM urls WHERE url LIKE '%peter%'

It would return 1 row.

You can also use NOT LIKE so you will get all the rows not containing the name.

Luud van Keulen
  • 1,204
  • 12
  • 38