MYSQL select where field does not contain a certain string character
25,124
Solution 1
SELECT * FROM pages WHERE some_col NOT LIKE './%';
This will fetch all rows where some_col is not starting with ./
Solution 2
Use LIKE
in mysql to check that it is not starting with ./
. Use the code below
SELECT * FROM pages WHERE col_name NOT LIKE './%';
Hope this helps you
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on December 04, 2020Comments
-
Admin over 3 years
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?
-
Admin almost 10 yearsWorks a treat, nice one : )