I know this is an old question, but for anyone still looking how to achieve this, the following query should do the job:
UPDATE wp_users
INNER JOIN wp_usermeta AS fn_meta ON wp_users.ID = fn_meta.user_id AND fn_meta.meta_key = 'first_name'
INNER JOIN wp_usermeta AS ln_meta ON wp_users.ID = ln_meta.user_id AND ln_meta.meta_key = 'last_name'
SET wp_users.display_name = CONCAT(fn_meta.meta_value, ' ', ln_meta.meta_value)
Basically you need to add two user meta joins – one to retrieve first name and another for last name, since they are stored in separate rows.
I would highly recommend testing this on a testing/staging server before running it in production.
Related Posts:
- Delete all post meta except featured image
- Emojis getting converted to “?”
- Select Multiple meta_value from WP DB; Single Query
- Delete all post meta except featured image Using SQL
- WordPress database import: Row size too large
- Changing root password in PHPMyAdmin for WordPress Database when going live
- Can’t update WordFence Options, clear data manually
- Files on Localhost, Database on Server
- Installing local to live WP into subdirectory
- Can’t log into wordpress site – I have made a new user and still cant access
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- Missing latest posts and options after DB migration via phpMyAdmin
- Check if a database is well installed
- Changed meta_key value in structures, now dashboard shows zero users
- Import Excel (or csv) Table with user-data as subscribers to wordpress
- Deleting WordPress posts and media files based on author via MYSQL database
- Rename a table in MySQL
- How should I tackle –secure-file-priv in MySQL?
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Checking if Database Table exists
- How to fetch Data in WordPress using MySQLi or $wpdb
- Connect to database using wordpress wp-config file
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- How to define composite keys with dbDelta()
- Is it possible to define two databases for one installation?
- Huge wp_options table
- “MySQL server has gone away” since update to 3.8
- How to track a users progress through pages by inserting data into WordPress Database?
- Can I transfer a mysql database to another site?
- MySQL Syntax Error upon restoring database from backup [closed]
- Help running a MySQL query to update all wp_#_options tables in a Multisite install
- How Do I Merge Categories With phpMyAdmin
- Size article thumbnails and retrieve them directly from database
- Accidentally deleted active_plugins portion of the wp_options DB table
- WordPress mysql table double prefixes
- In what part of the WordPress core does the users table and usermeta table get joined?
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Users table association with users_metadata table appears broken
- Why do mass updates to post_content shows in front end, but not in edit screen?
- Error establishing database connection – high traffic?
- wp_get_current_user always returns 0 continued
- How can i customize the export personal data file?
- WordPress Database Huge wp_usermeta Table
- Import users from old WP site to new one
- Create table from array with prepare
- How to Access wp_usermeta Data Immediately After a New User is Created
- Logins from WP users table use on another page
- How to prevent/delay MySQL connections when an object cache is used?
- Migrating from PDO using SQLite to clean new install using MySQL
- Better ads plugin has 500.000 entries in wp_postmeta
- Convert user passwords to MD5?
- Duplicated site isn’t recognized as a site
- Error establishing a database connection,
- How to properly check if a table exists in WordPress Database using Show Tables Query
- multiple wordpress installation with shared usertable on an different database
- Post Views / Hit Counter Problem?
- How and where is wordpress adding mySQL content to database?
- Best practice to import user base (subscribers) from one website to another?
- Some weird users in database
- How to delete a particular row in a database table
- How to create more than one new wpdb object?
- Recovering the table wp_usermeta from users
- Regenerate user_nicename column
- Remote database -> massive response time increase?
- Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
- Delete user with only subscriber role
- Is there any way to monitor a MySQL db and check what has changed?
- Replacing javascript link in WordPress database without getting mysql syntax errors
- How to edit custom table data in frontend
- User input to database
- local wordpress broke after changing URL
- how to access 2nd Mysqli Database from different server for wordpress
- Error establishing a database connection – WordPress setup, everything else is working
- Store GravityForm data in phpmyadmin (mysql)
- Change user_nickname for author page link
- What is recommended data type and encryption type for password in a database
- How to map data on CSV to web pages?
- WP website showing blank page after moving from subdomain to main domain
- create a table using user meta custom data
- How to create index (sql) to a meta_key?
- Search and Replace in Windows XAMPP site
- WPCLI search and replace in a particlar site dir effect another site-dir
- How to get the id of recently registered user from database?
- How can i syn wordpress user table with a stand-alone php script?
- insert data from a form:: Warning Empty query mysqli::query()
- How to get specific table by current user login
- WordPress Database Posts Table query
- Hang Up Followed By Can’t select database
- Mysql Queries per Visit – Crazy High
- using same mysql user with many databases
- Get id from database
- Why are my WordPress post queries so slow?
- import (migration) user database to wp-users
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- Custom wordpress SQL statement for a website
- WP Multisite Users Not Linking
- SQL errors when querying for something with apostrophes