php - wordpress sql regex to find urls starting with http not matching my own domain
I need an sql query to find all posts (insidepost_content
) containing urls starting exactly byhttp://
, but not matching my own domain to avoid finding posts containing internal links.
I know that it can be done and I'm currently using this:
$posts = $wpdb->get_results( "SELECT * FROM wp_posts WHERE post_content LIKE '%http://%' ORDER BY ID ASC" );
The problem with this is that I can find all urls starting byhttp://
, but I also see posts containing internal links.
Answer
Solution:
Is this what you want?