Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:11:36+00:00 2026-05-27T10:11:36+00:00

I have a query that fetches the list of user IDs and their corresponding

  • 0

I have a query that fetches the list of user IDs and their corresponding user names on a board but from another table also gets a column that has a value (a name) on the row corresponding to the user ID if said user has changed their name. Using an outer join I got the three nicely displayed as in the following example of a few of the results:

member_id    name             dname_current
1            Blablabla1       blablabla2
2            Bla4444          
3            RevZ             
5            Herpaderp42      
6            Lalalala         
7            Kaboom           
14           testtesttest21   Formula21
15           Alex             Ethan
16           Bob              Radio3

The SQL query to get the three columns is as follows:

SELECT
  data_members.member_id, 
  data_members.name,
  data_dnames_change.dname_current
FROM data_members LEFT OUTER JOIN data_dnames_change
    ON data_members.member_id = data_dnames_change.dname_member_id
GROUP BY data_members.member_id

Is there a way to display this so that it merges the values which exist in the ‘dname_current’ column of that other table into the ‘name’ column, replacing any value that’s already in the corresponding row of that column?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:11:37+00:00Added an answer on May 27, 2026 at 10:11 am

    COALESCE() returns the first non-null value, so you can do the following to prefer dbname_current over data_members.name unless it is NULL:

    SELECT
      data_members.member_id, 
      COALESCE(data_dnames_change.dname_current, data_members.name) AS name
    FROM data_members LEFT OUTER JOIN data_dnames_change
        ON data_members.member_id = data_dnames_change.dname_member_id
    GROUP BY data_members.member_id
    

    Should return:

    member_id    name
    1            blablabla2
    2            Bla4444
    3            RevZ
    5            Herpaderp42
    6            Lalalala
    7            Kaboom
    14           Formula21
    15           Ethan
    16           Radio3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following sql query that fetches images from an establishment table. The
I have a query that successfully grabs the unique products from my products table
I have a MySQL query that fetches a numeric value VARCHAR (20) from a
I have a server-side php-script that fetches results from a MySQL table. I am
I have the following table that fetches data from the database: while($row = mysql_fetch_array($result))
I have a simple application that fetches some data from ONE table on db
I have a table with a list of IDs. I use a query to
I have a Linq query that fetches data from database. The problem is I
Say I have a query that fetches [type][show_name]. For all [type]==5 records, I need
I have a query that basically combines tables of actions and selects from them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.