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
- #1067 – Invalid default value for ‘post_date’ when trying to create a new column
- 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)
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- MySQL SELECT increment counter
- phpMyAdmin – Error > Incorrect format parameter?
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
- How to create a foreign key in phpmyadmin
- importing a CSV into phpmyadmin
- Using wpdb to connect to a separate database
- MySQL Database User: Which Privileges are needed?
- Why is my database import losing text widget data?
- Multiple developers / editors working on a site in progress
- Will it break my site if I delete all transient records in wp_options table?
- Checking if Database Table exists
- WordPress (MyISAM) database is slow, should I switch to InnoDB?
- Please explain how WordPress works with MySQL character set and collation at a low level
- The MySQL alternatives: Do Percona Server and MariaDB work well with WordPress, and do they make WordPress go better?
- How many users can WordPress handle?
- How to fetch Data in WordPress using MySQLi or $wpdb
- WordPress Database lost auto increment
- Connect to database using wordpress wp-config file
- wpdb->insert multiple record at once
- Reset Post IDs to less than 64bit integer
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- Restoring WordPress posts from database only
- WordPress database scalability from the code perspective
- How to define composite keys with dbDelta()
- How to track user progress?
- Is it possible to define two databases for one installation?
- Does WordPress use the InnoDB engine for MySQL by default?
- Slow wp_term_relationships query
- How to use “TRUNCATE TABLE” MySQL statement?
- Can I use MariaDB instead of MySQL in wordpress?
- Performance tips for a large user base [closed]
- Using Dynamic Data Pulled from a MySQL Table in a WordPress Page
- WordPress for a very large website
- Changing user_nicename
- What are conventions about the schema of the $table_prefix
- Split WP install between 2 databases?
- Inserting Post Meta From SQL
- WooCommerce with thousands of products – site is very slow – optimize db queries? [closed]
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- Why does dbDelta() not catch MysqlErrors?
- Efficiency on displaying random authors based on large database
- Is deleting orphaned wp_options entries safe?
- Is altering a default WordPress database table update safe?
- How to solve slow WordPress site caused by attachment_metadata
- Huge wp_options table
- “MySQL server has gone away” since update to 3.8
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Custom DB_COLLATE (collation) value not working on fresh install?
- Export only pages and posts with mysql dump
- What causes the “max_user_connections” warning on WordPress frontend?
- How to track a users progress through pages by inserting data into WordPress Database?
- what to do when your WordPress database is too large?
- Extend the wp_users table
- Change all http to https in mysql databse?
- WooCommerce – Query for ordered products
- Large database causes slow load
- Error establishing a database connection – with Debug Data
- How to execute mulitple statement SQL queries using $wpdb->query?
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Database slowdown after update to 3.4.1
- Can I transfer a mysql database to another site?
- How to use user table of a different database for WordPress users?
- WordPress and automated MySQL backups to a different host
- Database with mixed collation (utf8mb4 & utf8_general_ci)
- Subscribers to posts
- Query WordPress database by registered date and role
- MySQL Syntax Error upon restoring database from backup [closed]
- Tons of Twitter rows in my database
- Help running a MySQL query to update all wp_#_options tables in a Multisite install
- How to insert data into MySQL database from the form created in WordPress site
- How Do I Merge Categories With phpMyAdmin
- Size article thumbnails and retrieve them directly from database
- WordPress site uses MyISAM, should I switch to InnoDB necessary?
- Is it safe to convert tables from MyISAM to InnoDB?
- How to replace values in WordPress DB using phpMyAdmin
- Migrating database / content of non-CMS site to WordPress