You must use a temporary table and an alias:
SELECT SQL_CALC_FOUND_ROWS *
FROM meruca_posts
WHERE ID NOT IN (SELECT ID
FROM (
SELECT object_id as ID
FROM meruca_term_relationships
WHERE term_taxonomy_id IN (14)
)
AS temp_object)
AND post_type="post"
AND post_status IN ('publish','private')
GROUP BY ID ORDER BY post_date DESC LIMIT 0, 10
Related Posts:
- simple sql query on wp_postmeta very slow
- How many WordPress SQL Queries per page?
- Multipart/formatted MySQL query problem
- Are database queries created using WordPress filters protected from SQL injection?
- Grouping related postmeta data via SQL query
- Mysql / WordPress killing my server with 80k users [closed]
- Slow meta_query with about 4 milion record on wp_postmeta
- Select User by Joining Multiple Meta Value Results
- mySQL query. ORDER BY meta_key
- Update slug (URL) of pending posts via phpMyAdmin
- My SQL function to change user_name
- You have an error in your SQL syntax – Help with query
- MySQL variable in query
- how would I create a custom query to get all users, and a related post based on a postmeta field?
- Help with MySQL to $WPDB query
- SQL query to select posts from multiple categories
- How do I see the mysql query generated by get_posts( $args )?
- Alter query with posts_clauses to retrieve NULL values last
- Searching With Apostrophe
- WordPress Query wp-terms SLOW
- wpdb COALESCE won’t work
- Get posts from category with custom query
- how to insert missing tags into the posts through mySQL?
- Ideas how to search & replace post_content when string contains a newline?
- Valid SQL query return empty
- mysql query – how to escape apostrophe?
- Query the WordPress database to get data together with replaced information
- Optimize slow SQL query for multiple meta values
- Updating with $qpdb->query() always returns 0 rows affected
- How to return count of custom post type posts with a specific custom field value via $wpdb?
- WordPress Mysql query and Duplicate
- Help with Related Posts Function
- How to delete all images from code in all post_content
- I want to get on those users their meta value are like “AGENT” .. but this query is not working
- Displaying data from custom table
- Get 2 meta values from meta key column
- PHP Fatal error: Uncaught Error: Call to a member function insert() on null
- SQL query to delete users with multiple meta keys and comments
- OR condition not working
- Trouble migrating custom post types from non-wordpress cms
- Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?
- Performance of wp_get_attachment_image_srcset() and wp_get_attachment_image_url()
- How to make MySQL search queries with quotes
- Custom MySQL Query for Post and Post Meta
- Mysql query and odd results
- sql for querying post and their category
- Access Tables with number prefix
- What SQL Query to do a simple find and replace
- How to Optimize WP site for millions of posts
- Get Terms by IDs with IDs order
- Slow wp_enqueue_media()
- Advanced Custom Fields – Query Efficiency
- How to display lastest post date in the homepage?
- The use of including upgrade.php when building custom queries
- WordPress Find Duplicate Post By Content
- WP Query Sort by meta value (date)
- how to query multiple categories in wordpress?
- Disable the MySQL query in the main query
- Strange string in console from wpdb query
- How can I get the query that would be run for the archive page?
- Query metas (and not : query posts by metas)
- Select query for a login
- What’s wrong with my $wpdb prepare?
- where should I reset query after using get_results?
- wpdb print all post meta
- Long running queries
- Form and custom query problem
- Export Specific User data without plugin
- I want to create a filter for the query string is this possible?
- Exclude categories from the_category();
- How can i show all categories using wp query?
- Query returning same results even though the ID changes
- Why my query ‘REPLACE INTO…’ does not work?
- DELETE WooCommerce Order data from database
- Restrict query to last day with posts
- Custom query object with Simple-Fields custom date field
- How to read the value of a WordPress $query associative array (hash) key
- Query posts based on previous query
- Waypoints + infinite scroll with custom query
- Customizing the_tags output?
- Querying with WP query using meta key price
- Re-sort get_posts query results
- How do I get all results from my query
- create a link to a random post within the current category
- Pagination not working on custom post types with rewrite slug
- Filter orders by modify date
- How to add url parameter to every search query in SearchWp?
- Woocommerce Get Orders By Meta Value
- Sort by postmeta on when searching
- Pulling an ACF into a query
- Using cron for multiple queries
- Set posts per page for parent category and it’s all children
- Exclude sticky posts from query
- If more than 1 image show post link?
- Rewrite Query_Var URL Parameter with Slug
- How to query different categories on index?
- How to specify what kind of is_single post?
- Print data from wordpress sql query
- Can I create my own query in wordpress with traditional methods?
- How to figure out correct wp_options to have autoload=’yes’