My current query (doesn\'t work)
SELECT url
FROM table
WHERE
\'http://www.longurl.com/some/string\' like \'%\' . url . \'%\'
table
this?
SELECT url
FROM table
WHERE
url like '%http://%longurl.com%'
or you can also use %longurl.com%
Are you looking for:
LIKE '%longurl.com%'
If what you need is getting all URLs containing longurl.com
then try using:
SELECT url
FROM table
WHERE
url like '%longurl.com%'
It should work.
The concatenation operator .
does not exist in MySQL, you have to use the CONCAT() function instead:
SELECT url
FROM table
WHERE 'http://www.longurl.com/some/string' LIKE CONCAT('%', url, '%');
What about this:
SELECT url
FROM table
WHERE url LIKE '%longurl.com%string%'
or, to be just like your PHP:
SELECT url
FROM table
WHERE url LIKE '%longurl.com%'
Okay, what about:
SELECT url
FROM table
WHERE INSTR('http://www.longurl.com/some/string', url) > 0
(Formatting didn't work so well in the comments, so I added it again as an answer.)