Query SQL: Get display_name from user_id
-
Hello,
below query works fine and result is:
POST_ID: 1
FIRST_AUTHOR: ADMIN
SECOND_AUTHOR: 5
SELECT posts_post.ID AS post_ID, posts_post_author.display_name AS First_Author, meta1.meta_value AS Second_Author FROM wp_posts AS posts_post INNER JOIN wp_users AS posts_post_author ON posts_post_author.ID = posts_post.post_author INNER JOIN wp_postmeta meta1 ON meta1.post_id = posts_post.ID AND meta1.meta_key = 'user_id' WHERE 1=1 AND posts_post.post_type = 'post' AND posts_post.post_status = 'publish'
How can I convert into the query, the “second_author: 5” record that results as USER_ID and get DISPLAY_NAME result?
Could you help me with join to wp_users?
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Query SQL: Get display_name from user_id’ is closed to new replies.