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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:34:56+00:00 2026-05-25T10:34:56+00:00

I need to write an SQL query to take either from one of two

  • 0

I need to write an SQL query to take either from one of two column’s data(based on whichever is available and not null) and append it to a static text into another column within the same table.

Can anybody tell me how to write this?

Example Data :

ID  Type   Barcode  Serial No  Location

1   Test    ABCD     1234       LOC1  
2   Test    EFGH     NULL       LOC2  
3   Test    NULL     5678       LOC3  
4   Test    NULL     NULL       LOC1  

Final Data Reqd in Format

ID  Type  Barcode  Serial No  Location

1   Test  ABCD     1234       LOC1-ABCD   (Append barcode if its not null)  
2   Test  EFGH     NULL       LOC2-EFGH   (Append barcode if its not null)  
3   Test  NULL     5678       LOC3-5678   (Append serial no since barcode is null)  
4   Test  NULL     NULL       LOC1        (Both r Null keep loc as it is)  

Please help me on it….really stuck on this 🙁

Database is Oracle 10.

Supra

Update 1 :

Thanks a lot Marco for your help….the location field only needs to updated in the table after appending the barcode/serial no from the same table into location field. Your edited query is not working :(…please let me know if I need to give some more info/data.

Final Update :

Shesek’s Answer worked perfect :D…you are the man :)…Thanks a ton 😀

  • 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-25T10:34:57+00:00Added an answer on May 25, 2026 at 10:34 am

    According to your comment on the other answer,

    UPDATE Network_Plant_Items
        SET FULL_ADDRESS = 'foobar' || COALESCE(BARCODE, MANUF_SERIAL_NUMBER)
        WHERE BARCODE IS NOT NULL OR MANUF_SERIAL_NUMBER IS NOT NULL
    

    If you want to append this to the current value of FULL_ADDRESS, as I understand from the original question,

    UPDATE Network_Plant_Items
        SET FULL_ADDRESS = FULL_ADDRESS || COALESCE(BARCODE, MANUF_SERIAL_NUMBER)
        WHERE BARCODE IS NOT NULL OR MANUF_SERIAL_NUMBER IS NOT NULL
    

    COALESCE() returns the first non-NULL argument you pass to it. See Oracle’s manual page on it.

    Just as a general FIY, NVM() that was suggested by another answers is the old Oracle-specific version of COALESCE(), which works kinda the same – but it only supports two arguments and evaluates the second argument even if the first one is non-null (or in other words, its not short-circuit evaluated). Generally, it should be avoided and the standard COALESCE should be used instead, unless you explicitly need to evaluate all the arguments even when there’s no need for it.

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

Sidebar

Related Questions

I need to write a sql query that adds one column from one database
I need to write a SQL query which will get me those rows from
I need to write some data to SQL Server database from Linux in C++.
I'm trying to write an SQL query that will gather certain data in one
Need to write a SQL query to search special character in a column. Text
Since i'm a poor sql developer, i need support to write a sql query
I need to write some sql that will allow me to query all objects
I need to write a query on SQL server to get the list of
Im very new to SQL but need to write a query to do the
I need to write a Stored procedure in SQL server whose data returned will

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.