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
- 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)
- phpMyAdmin – Error > Incorrect format parameter?
- Why is my database import losing text widget data?
- 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
- Getting all the users who have author privilege
- 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?
- 2 WordPress sites with 2 databases but sharing the same users
- Convert user passwords to MD5?
- Error establishing a database connection,
- Changing between Local Host DB to Production DB and in reverse
- 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?
- Users table missing from Database [closed]
- Some weird users in database
- Query Column of Specific ID from Database Table
- How to delete a particular row in a database table
- How to create more than one new wpdb object?
- SELECT SQL_CALC_FOUND_ROWS with wordpress search
- How to connect and insert data in database of wordpress?
- Regenerate user_nicename column
- Buddypress avatar image in database [closed]
- Storing user submitted forms [closed]
- Remote database -> massive response time increase?
- wp_insert_user not creating account correctly when ID is manually set
- Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
- Cloning blog to localhost via WAMP
- Only allow user to access a link once a year, based on their joining date
- Delete user with only subscriber role
- MSQL database wp_postmeta has meta key tve_revision
- How to edit custom table data in frontend
- Display user data in numbered list
- local wordpress broke after changing URL
- “BS_” rows in postmeta table
- Move Non-WordPress users table to WordPress database
- Exporting Post ID, Post Title, Primary Category and Primary Category ID
- how restrict user to give star ratings once for a post?
- Duplicate database to roll back theme & content changes
- 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?
- WPCLI search and replace in a particlar site dir effect another site-dir
- mySQL database size large, but tables size less
- How To connect to the same WordPress database with different database user
- Hang Up Followed By Can’t select database
- WordPress character set issue
- Why is converting my database to UTF-8 truncating entries?
- Let users register weight each day and save it in DB
- import (migration) user database to wp-users
- Database question while Migrating from one domain to another on same WebHost [Bluehost]
- export individual posts to text files or a single csv file
- Uploading to WordPress Database
- Have WordPress Use a Different Database for users