Add following in WHERE
condition of your SQL query.
WHERE t1.meta_key = "<?php echo $wpdb->prefix; ?>capabilities"
AND ( t1.meta_value LIKE '%ROLE_YOU_WANT_TO_FILTER%')
Let me know if it works for you or not.
Related Posts:
- WordPress Database Huge wp_usermeta Table
- How to migrate a database from a server to another
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- WordPress character set issue
- What is “Advanced” SQL?
- Oracle SQL query for Date format
- WPDB Insert or if exists Update
- Where are image paths to product category images stored in WordPress database
- Sharing database for collaborative development
- Organizing WP Pages based on old website database
- Inserting Post Meta From SQL
- Moving an entire wordpress site from one domain to a new domain and database
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Delete all post meta except featured image
- wpdb query on custom table not working [closed]
- How to execute mulitple statement SQL queries using $wpdb->query?
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- Using table lock with wp_insert_post?
- How to Move Local Singlesite Database to Remote Multsite Database?
- Scheduling posts in database
- Set Display Name to first and last name (phpmyadmin SQL Query)
- Size article thumbnails and retrieve them directly from database
- How to replace values in WordPress DB using phpMyAdmin
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Delete all post meta except featured image Using SQL
- wpdb_prepare with multiple or condition
- Uppercase to sentence case for post titles
- SQL Error wp_commentmeta – incorrect table definition
- phpMyAdmin displays error when importing database
- change wp user status from wp_users table
- How do I get the posts within a certain year/date(with sql query)?
- WordPress database import: Row size too large
- Export / import WordPress database
- WordPress is not creating table in database after activating plugin,
- Bulk-create posts from SQL database
- Difficulty importing my live site to local
- Setup private content for specific users with daily updates [closed]
- Connection refused on locahost after importing database?
- Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?
- Insert Query not working in the form
- WPDB SQL query with prepare() returning variable, not db value
- Problems with moving my WordPress site to another domain/server
- Changing root password in PHPMyAdmin for WordPress Database when going live
- Post Views / Hit Counter Problem?
- Why this query is not showing any result on wordpresss home page?
- pull data from a remote wordpress database
- Clear Terms from Taxonomy for Specific Post IDs?
- Is my way to change WordPress server is correct?
- Why does changing Database Table Prefixes result in loss of content?
- Options on how to Display member specific data from a MS SQL database
- SQL query to set posts in bulk based on the post content
- Delete all posts that do NOT have a specific tag
- Location of WP default mySQL tables creation file?
- SELECT SQL_CALC_FOUND_ROWS with wordpress search
- Files on Localhost, Database on Server
- Backing up WordPress database and files
- $wpdb->get_var – What value is returned when zero records are found?
- How to display data from db in select list [closed]
- wp_option table error while importing
- Installing local to live WP into subdirectory
- WordPress SQL – How to Check for Category?
- Can’t log into wordpress site – I have made a new user and still cant access
- Is there any way to monitor a MySQL db and check what has changed?
- Counting post and changing roles in mysql database. Query not code
- Deleting empty meta key values
- Sql query to get all metadata for a post
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- Job and Employee Performance Tracking with Product Safety
- I need to find posts that contain YouTube links without http:// or https:// prefix and add http:// to all of them
- Is there any defects for using same database prefix in WordPress for multiple sites?
- Migrating meta_key and meta_value from old theme to new one
- SQL database import #1046 error
- What is recommended data type and encryption type for password in a database
- syntax error for changing user role from database
- How do I loop/iterate through posts to edit all img tags?
- What’s the easiest way to connect external database and display data on wordpress?
- Duplicate database to roll back theme & content changes
- Is there a way for two deferent themes to consume two different DB on a same WP instance?
- How to set posts to draft in bulk based on the content of the post
- 2 $wpdb queries causing error Table ‘wp_postmeta’ is specified twice, both as a target for ‘UPDATE’
- Delete all users meta that named: user_avatar
- Correct and secure way to access a custom SQL database in a custom PHP template file
- How to get specific table by current user login
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- $wpdb not working
- Missing latest posts and options after DB migration via phpMyAdmin
- Check if a database is well installed
- Options table – where does my values go?
- How to add data from wordpress tables to new database tables you have created
- Getting deleted users in database
- Install WordPress with SQL database
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- SQL query : Select a thumbnail for a media
- why you don’t Implement PDO for access every thing to database
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- SQL query to rewrite all media URLs to end with .webp
- Weird WP -Cli Error Connection Refused