There are a few ways you could do it- NOT IN
, NOT EXISTS
, IS NULL
. Which method is best depends on your actual query.
SELECT *
FROM $wpdb->posts LEFT JOIN $wpdb->postmeta
ON $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = 'somekey'
WHERE $wpdb->postmeta.post_id IS NULL
Related Posts:
- Export WordPress Posts and Meta Information in CSV format
- How do I find which articles are missing a featured image in The WordPress database?
- SQL DELETE multiple post_meta on single and multi-sites
- Bulk find & replace on WordPress posts/pages (minus image paths)
- WordPress MySQL Search and replace with wildcard?
- Add postmeta to all blog posts
- SQL query to remove first image in all posts
- Delete junk text from all the post using my sql command
- How to check if post meta key exists or not in wordpress database
- How to add category to: ‘wp-admin/post-new.php’?
- How can I retrieve multiple get_post_meta values efficiently?
- Code to make a post sticky
- MySQL Query to Retrieve Category from wp_posts
- How to allow hidden custom fields to be added from wp-admin/post.php?
- SQL Query for getting all posts in their latest revised state
- Delete duplicated wp_postmeta record
- Will a large postmeta table slow a site down?
- Update all posts automatically when using post_meta
- Search & Remove Specific Shortcode From All Posts
- Manually delete post from database
- How to batch update post content with custom post meta value
- how to get permalink using sql
- Change slug with custom field
- Better post meta efficiency?
- How to force update all posts after import
- Setting post meta data to random value during post status transition / on publish
- Edit meta data does’t work with custom sql
- Human Time Diff, change mins to minutes
- Change post format using custom field
- Does WP get all post_meta on POST page?
- Use Cron to modify posts via sql
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Query All users that has post
- Exporting Data from WordPress into a flat table
- Adding Multiple Values to a Post Meta Key
- Sql syntax error
- Using radio button meta data from a custom meta box
- get posts and postmetas in assoc array
- Can’t publish new posts
- PHP Notice error (when on 404 page)
- What Is meta_id In wp_postmeta?
- Manually removing revision post types
- Checking if a post with certain meta value exists
- How to permanently delete a post meta entry?
- Reset/Reorder posts ID in the MySQL wp_posts table
- Add custom field automatically (add_post_meta) with value based on number of words of article
- How to generate numbers indistinguishable for the IDs of the posts
- Modify WP_Post before processing
- Save re-arranged draggable post items to wordpress database
- Bulk update post slugs through database
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Change post_date to post_modified date on post template?
- Tags to Post-ID mysql query. Tag Search
- Get the most repeated post contents from a search?
- Multiples Empty Posts were created and cannot delete them
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Delete WordPress posts from URL list sql query
- SQL query to retrieve all the records that have not indicated category
- How can I sort posts by the date and a custom meta field?
- is there a way to show the the post title after the image?
- Get Meta Key Value While Saving Post
- wp_insert_post – duration
- How to verify wp user password by sql query in wp? [closed]
- Get ALL post ID’s export list (Only id’s. Php or sql not important )
- Force the “Choose from the most used tags” meta box section to always be expanded
- Meta value does not save for scheduled posts
- Custom Posts Query and meta_query Sort Order
- Get user categories with most posts in it
- MySql query to get posts with all meta and terms
- How to compare two posts including their meta fields on a scalable base?
- Getting value from get_post_custom
- Calling Different Custom Post Timestamps in a table
- Is it possible to paste a link without tags and make it directly a link in a post?
- Cannot retrieve a custom RSS field from posts
- Custom order for Mysql array
- List authors with the last post title and order by last post date
- Saving custom fields to a custom taxonomy
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Remove a shortcode from all WordPress posts
- Order posts alphabetically: how to set order=asc in mysql query?
- How to automate featured posts number? [duplicate]
- What do these phpMyAdmin errors mean on my WordPress databaes?
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”
- Customize rel=canonical tag for single blog post
- Change all author links in Blog roll
- How to I retrieve the ID from the Posts page?
- WordPress website loads more posts than expected
- How to save meta checkbox WordPress
- SQL Command for restoring trashed comments
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- How to calculate the average of a post meta value(Numeric) of a specific author
- Is there any way to tell when wp_postmeta has been updated?
- update image path with words starting uppercase to lowercase chars
- wpColorPicker – problem with implementation to post meta
- Change post author without using wp_update_post()
- if in category but only with post meta
- How to Assign / Move all Deleted post to a category
- Migrate posts from category and sub-category via SQL