I am trying to search the wordpress posts in my database, that match a string.
However i want to get the rows that have the matching words in them as a plain text, but not the ones that have the word embedded inside a link.
For example, if a post has the following text in ‘wp_posts’ table of database:
'This is a Test page: <a href="http://localhost/test-page">About Test</a>'.
And i search for the word ‘about’ in my custom query:
SELECT * FROM `wp_posts` WHERE post_content like '%about%';
so i am getting the above post as the result.
Is there a way i can ignore the posts that have the search string embedded inside a link, and fetch other posts which have the search string as part of a normal string?
I tried a REGEX query, with no luck:
SELECT * FROM `wp_posts` WHERE post_content REGEXP '[[:<:]]about[[:>:]]';
May be this :
Try this
Here is the Fiddle
in sqlfiddle it works fine!
http://sqlfiddle.com/#!2/f1697/2
Create script
Select