MYSQL select where field does not contain a certain string character

user3468325 picture user3468325 · Aug 18, 2014 · Viewed 22.7k times · Source

I use sql to select all my sites URLs from a table.

$sql = 'select * from pages where "myURL field";

However I want to be a little more specific with my query. There are a few duplicate links in my table for example:

about-us
./about-us

I don't want the ./about us field to be selected. Is there a way of saying:

select * where "myURL field" does not begin with . /

Or should I just forget it and parse using PHP?

Answer

Dennis Schepers picture Dennis Schepers · Aug 18, 2014
SELECT * FROM pages WHERE some_col NOT LIKE './%';

This will fetch all rows where some_col is not starting with ./