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 9062113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:39:20+00:00 2026-06-16T15:39:20+00:00

I have a situation where a user may or may not provide various bits

  • 0

I have a situation where a user may or may not provide various bits of data that need to go into a row containing that user’s info. The issue is that they need to make multiple entries into the row, over time, and I don’t want to null out any pre-existing values, if those had been set in the past.

My desire is to do something that looks (in pseudo code) like this:

var a,b,c;// these are the values that the user provides any of which may be null at any time

update user if a != null set name = a,  if b != null set phone = b, if c != null set email c

I’ve been trying to fashion an IF to work in this manner but I get syntax errors with the various ways I’ve tried. Hoping someone can shed light on the right way to do this (if it’s possible).

TIA

  • 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-06-16T15:39:21+00:00Added an answer on June 16, 2026 at 3:39 pm

    One way to do this is to “default” each column to its original value with COALESCE().

    UPDATE user
    SET name = COALESCE(a, name),
        phone = COALESCE(b, phone),
        email = COALESCE(c, email)
    WHERE ...
    

    COALESCE() returns its first non-null argument, so if a is null, it’ll just return the original value of name, so there will be no net change.

    MySQL also supports a function ISNULL() which works like COALESCE(), but COALESCE() is standard SQL. Also, COALESCE() supports more than two arguments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where in a web application a user may need a
I have situation where a user can manipulate a large set of data (presented
My situation is that I have a video gallery where when a user clicks
I am facing a situation and need help. I have two tables: user: user_id
Here is the situation, I have registration page that allows user to signup but
I have a scenario that a user may enter a format string to format
I have situation like this: user submits form with action='/pay' in '/pay' I have
I have a situation where user requests to do a long running process. I
I have a situation in which user can single tap a control, which show
I have a situation where i have to take input(form) from user. After continue

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.