Look into MySQL Wildcards.
The correct MySQL Query for your search should be
WHERE tb_posts.post_content LIKE "%example.com%"
You should also be sure that you only target published posts (in contrast to nav_menu_items, revisions etc). Expand your WHERE with this:
AND tb_posts.post_type IN ('post','page',*All Posttypes you use additionally*) AND tb_posts.post_status="publish"
So your complete Query should look like this (assuming that you only use posts and pages):
UPDATE tb_posts
SET post_status="draft"
WHERE post_content LIKE "%example.com%"
AND post_type IN ('post','page')
AND post_status="publish"
Happy Coding!
Related Posts:
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- Inserting Post Meta From SQL
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Change all http to https in mysql databse?
- WooCommerce – Query for ordered products
- How to execute mulitple statement SQL queries using $wpdb->query?
- Size article thumbnails and retrieve them directly from database
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Select Multiple meta_value from WP DB; Single Query
- wpdb_prepare with multiple or condition
- SQL Error wp_commentmeta – incorrect table definition
- CRUD operations using WordPress database API
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- How do I get the posts within a certain year/date(with sql query)?
- Advanced SELECT query with condtional statements
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- Create table from array with prepare
- Query multiple tables at once?
- Custom WordPress Table wpdb
- Why this query is not showing any result on wordpresss home page?
- Best practice to limit results in get_row()?
- Why does changing Database Table Prefixes result in loss of content?
- Query Column of Specific ID from Database Table
- $wpdb->get_var – What value is returned when zero records are found?
- How to display data from db in select list [closed]
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- Job and Employee Performance Tracking with Product Safety
- WordPress Database Query works in phpMyAdmin but not in the code
- How to create index (sql) to a meta_key?
- Delete all users meta that named: user_avatar
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- export individual posts to text files or a single csv file
- SQL query : Select a thumbnail for a media
- why you don’t Implement PDO for access every thing to database
- SQL query to rewrite all media URLs to end with .webp
- #1067 – Invalid default value for ‘post_date’ when trying to create a new column
- Deleting WordPress posts and media files based on author via MYSQL database
- SQL errors when querying for something with apostrophes
- How to optimise this database query?
- How to retrieve user data based on role using SQL?
- How can we speed up wp_get_nav_menu_items()?
- spambot registering without providing email or password, bypassing registration process
- After renaming MySQL database, I can no longer access my Blog page
- $wpdb not working
- Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?
- How To connect to the same WordPress database with different database user
- Possible to restore wordpress database from mysql56 and sqlite files?
- WordPress Database Posts Table query
- Extracted CSV as Array for Custom Query Loop
- Hang Up Followed By Can’t select database
- WordPress character set issue
- Should I Use only wpdb Class to Write Custom Queries?
- Generating an HTML table from an array based on dynamic key values
- How to extract some part of WordPress full source code
- can’t delete a row from post_meta table
- Mysql Queries per Visit – Crazy High
- How to make MySQL search queries with quotes
- Missing latest posts and options after DB migration via phpMyAdmin
- Get multisite count without php?
- WP_Query always returning the last custom post
- Check if a database is well installed
- Create a new table on the database and save parameters from a contact form
- live site do not update after importing sql database
- Link wordpress with a SQl + MongoDB + .NET
- Why is converting my database to UTF-8 truncating entries?
- Widgets with *internal* links do not display after database migration
- using same mysql user with many databases
- How do i get value from wp_postmeta?
- Pulling values from a sepcific row in table
- How to add data from wordpress tables to new database tables you have created
- “MySQL server has gone away” since update to 3.8
- Why are my WordPress post queries so slow?
- featured image not showing up with mysql_connect
- MySQL Database User: Which Privileges are needed?
- Import Excel (or csv) Table with user-data as subscribers to wordpress
- Using class id from array for query
- Getting deleted users in database
- Print output of Table Creation
- Install WordPress with SQL database
- How to back-up a database on IIS
- database search feature
- Importing Concrete5 content to WordPress
- Custom wordpress SQL statement for a website
- How do I find users by password?
- Weird WP -Cli Error Connection Refused
- WordPress database connection failed, while mysql client is working [closed]
- Change permalinks in posts via SQL
- How to find fresh (last modified) and sql backup?
- Uploading to WordPress Database
- Have WordPress Use a Different Database for users
- How to generate PDF dynamically based on values from the database in WordPress
- Understanding Redundant postmeta Tables in WordPress Database
- Remove posts that start with similar words (like a delete duplicate posts plugin)
- Database table prefix different between wp-config.php and in database
- Naming conventions for database tables
- WordPress User Login not accepted although listed in DB