How about a Pivot Query?
This would return rows that have first_name,last_name,user_login. You could then add whatever condition you wanted using a WHERE clause.
SELECT
MAX(CASE WHEN wp_usermeta.meta_key = 'first_name' then wp_usermeta.meta_value ELSE NULL END) as first_name,
MAX(CASE WHEN wp_usermeta.meta_key = 'last_name' then wp_usermeta.meta_value ELSE NULL END) as last_name,
wp_users.user_login
FROM wp_users
LEFT JOIN wp_usermeta
ON wp_users.ID = wp_usermeta.user_id
GROUP BY wp_users.user_login
Related Posts:
- Select Multiple meta_value from WP DB; Single Query
- Which is more efficient? Using usermeta, or creating a new MySQL table?
- Buddypress avatar image in database [closed]
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- MySQL SELECT increment counter
- phpMyAdmin – Error > Incorrect format parameter?
- MySQL Database User: Which Privileges are needed?
- Why is my database import losing text widget data?
- Will it break my site if I delete all transient records in wp_options table?
- Please explain how WordPress works with MySQL character set and collation at a low level
- Reset Post IDs to less than 64bit integer
- Restoring WordPress posts from database only
- WordPress database scalability from the code perspective
- Does WordPress use the InnoDB engine for MySQL by default?
- Can I use MariaDB instead of MySQL in wordpress?
- Using Dynamic Data Pulled from a MySQL Table in a WordPress Page
- Split WP install between 2 databases?
- Inserting Post Meta From SQL
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- Why does dbDelta() not catch MysqlErrors?
- Is deleting orphaned wp_options entries safe?
- Is altering a default WordPress database table update safe?
- What’s the most efficient database method to add and query usermeta?
- How to solve slow WordPress site caused by attachment_metadata
- Delete all post meta except featured image
- Custom DB_COLLATE (collation) value not working on fresh install?
- What causes the “max_user_connections” warning on WordPress frontend?
- what to do when your WordPress database is too large?
- Extend the wp_users table
- Change all http to https in mysql databse?
- Large database causes slow load
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- WordPress and automated MySQL backups to a different host
- Size article thumbnails and retrieve them directly from database
- WordPress site uses MyISAM, should I switch to InnoDB necessary?
- update_user_meta() does not work
- Is it possible to store visitors IPs in wp_postmeta table?
- WordPress mysql table double prefixes
- A field with dashes in the slug [closed]
- Best way to tell if a user account is active, using the database only
- WordPress database import: Row size too large
- Advanced SELECT query with condtional statements
- Why do mass updates to post_content shows in front end, but not in edit screen?
- Error establishing database connection – high traffic?
- Handling large N data in WordPress
- Is MariaDB’s Aria storage engine suitable for WordPress?
- Is it safe to delete unnecessary user metadata?
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- Improve performance by removing unnecessary database queries
- Redirecting to old domain after migration website
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- WordPress Database Huge wp_usermeta Table
- A MySQL DB within a MySQL DB
- How do I query wp_options for expired transient pairs with MySQL commands?
- Switching Databases in LocalHost
- Is there a way to recover the table wp_term_relationships?
- Trouble Migrating all data blog from WordPress.com to WordPress.org
- Unable to set a default serialized array using dbdelta()
- WordPress running SQL query to update database from form
- How to fix database error duplicate entry
- How do I convert a MySQL database from utf8mb4 to utf8 encoding?
- Why this query is not showing any result on wordpresss home page?
- Best practice to limit results in get_row()?
- Users table missing from Database [closed]
- Why does changing Database Table Prefixes result in loss of content?
- Moving WordPress site to new domain – database import [duplicate]
- How to connect and insert data in database of wordpress?
- wp_usermeta – Read from database, but save function broken
- $wpdb->get_var – What value is returned when zero records are found?
- wp_insert_user not creating account correctly when ID is manually set
- Installing local to live WP into subdirectory
- Only allow user to access a link once a year, based on their joining date
- Counting post and changing roles in mysql database. Query not code
- MSQL database wp_postmeta has meta key tve_revision
- Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- “BS_” rows in postmeta table
- How can I find user role in Mysql?
- Featured image from custom to WordPress database
- WordPress Database Query works in phpMyAdmin but not in the code
- Delete all users meta that named: user_avatar
- mySQL database size large, but tables size less
- spambot registering without providing email or password, bypassing registration process
- update multiple user meta field based on another meta field
- After renaming MySQL database, I can no longer access my Blog page
- How To connect to the same WordPress database with different database user
- Possible to restore wordpress database from mysql56 and sqlite files?
- Create a new table on the database and save parameters from a contact form
- Widgets with *internal* links do not display after database migration
- How do i get value from wp_postmeta?
- Preventing concurrent update of data
- featured image not showing up with mysql_connect
- Calling update_user_meta inside of another function doesn’t work
- How to back-up a database on IIS
- Importing Concrete5 content to WordPress
- 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
- wp_usermeta key problem
- How to find fresh (last modified) and sql backup?
- Uploading to WordPress Database