Try this one with additional join on metadata
SELECT u.ID, u.display_name
FROM wp_users u
LEFT JOIN wp_usermeta um1 ON u.ID = um1.user_id
LEFT JOIN wp_usermeta um2 ON u.ID = um2.user_id
WHERE um1.meta_value="value1" AND um1.meta_key = 'key1'
AND um2.meta_key = 'keyA' AND um2.meta_value="valueA"
GROUP BY u.ID
Also use group by
Related Posts:
- simple sql query on wp_postmeta very slow
- How many WordPress SQL Queries per page?
- Multipart/formatted MySQL query problem
- SQL query equivalent to WP User Query
- 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 Multiple meta_value from WP DB; Single Query
- 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
- Plugin will sort users by usermeta
- MySql Query very slow
- Searching With Apostrophe
- WordPress Query wp-terms SLOW
- Problem when try to add ++1 for user meta
- wpdb COALESCE won’t work
- Get posts from category with custom query
- How to exclude posts for current user
- 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
- Query Nickname rather than Display Name in custom Woocommerce plugin
- 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
- Combining two meta_values within one row with query
- 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
- How to do a sql like query on serialized data of user meta data
- 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
- Querying users by meta value and getting a strange answer
- Update vs Insert logic but the last key is always inserted?
- Custom MySQL Query for Post and Post Meta
- Mysql query and odd results
- list or get meta_key where meta_value is ‘something’
- sql for querying post and their category
- Access Tables with number prefix
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- Compare two numeric custom fields
- How to extract all ID variables from a query string?
- Query All users that has post
- Remove Unnecessary Mysql Query
- Is it good practice to use wpdb->query() function?
- wpdb::prepare() isn’t working
- How can I apply a meta query for a single custom post type in the main query?
- how to query multiple categories in wordpress?
- Strange string in console from wpdb query
- where should I reset query after using get_results?
- Using GROUP CONCAT in my-sql query with wp_usermeta table
- Exclude featured image and custom field from this get_attachment query
- Long running queries
- Form and custom query problem
- Export Specific User data without plugin
- Exclude all sticky posts front page twenty twelve
- get csv of users with user_meta
- Custom SQL Query passing array to WHERE p.id
- Run Username SQL Query from WordPress Child Theme Functions File
- get posts by tag to showing in a widget
- Edit Account – read and write to MySQL
- Mysql query not working on WordPress 4.2.2
- mySQL queries are executed twice on wordpress website
- get_post_meta with WP_query
- How properly create a blog template for wordpress?
- Is there a way to add a link directly into this media query?
- meta_query not working
- Cannot get sql request from Query object?
- WordPress query: merge meta key (number) values and sort
- Question about of query
- Modify behaviour of “s” parameter in wp_query
- Plugin MySQL SELECT custom data and filter on user meta
- Include a custom field in mysql query
- Limiting a filtered query
- WP_Query always returning the last custom post
- learn to run wpdb class
- Display old posts if no future posts exist
- how to add a read more button to my blog page?
- Query parsing only author ids
- Ascending & descending posts on same page with IF statement
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155