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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:38:24+00:00 2026-05-25T16:38:24+00:00

I want to update several columns of a table at the same time. And

  • 0

I want to update several columns of a table at the same time. And the value for each column is retrieved from several tables. My tables are:

Table : Customer
Columns are:
customerCode
kategori
design
designCode
value

Table Name : Customer_kategori 
Columns:

customerCode
kategori

and similar …..

My sql query is:

UPDATE Customer
SET 
    kategori = Customer_kategori.kategori,
    design = Customer_design.design,
    designCode = Customer_designCode.designCode,
    value = Customer_value.value

FROM 
     Customer_kategori,
     Customer_design,
     Customer_designCode,
     Customer_value
WHERE
     Customer_kategori.customerCode = Customer.customerCode
     AND Customer_design.customerCode = Customer.customerCode
     AND Customer_designCode.customerCode = Customer.customerCode
     AND Customer_value.customerCode = Customer.customerCode

The columns are updated if all the tables (Customer_kategori, Customer_design, Customer_designCode, Customer_value) contains values. But if tables are empty,
columns are not updated as Where condition is not satisfied.

I also try using CASE in WHERE Condition. My code is ,

WHERE
        Customer_kategori.customerCode = CASE WHEN Customer_kategori.customerCoder IS NOT NULL THEN Customer.customerCode END
        AND Customer_design.customerCode = CASE WHEN Customer_design.customerCode  IS NOT NULL THEN  Customer.customerCode  END
        AND Customer_designCode.customerCode = CASE WHEN Customer_designCode.customerCode  IS NOT NULL THEN  Customer.customerCode  END
        AND  AND Customer_value.customerCode =   CASE WHEN Customer_value.customerCode  IS NOT NULL THEN  Customer.customerCode  END

But this does not work either. I also try to check the table,
with following where clause,

WHERE
    CASE WHEN (select count(Customer_kategori.customerCode) > 0 from Customer_kategori) THEN Customer_kategori.customerCode = Customer.customerCode END

But no success..

In short:

  1. I want to check if tables are empty in WHERE clause
  2. And if it is empty I just want to ignore checking columns of those table that are empty.

Or may be there is other better way ….
Any suggestion is appreciated…

Thank you

  • 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-25T16:38:25+00:00Added an answer on May 25, 2026 at 4:38 pm

    Will this work?

    WHERE
    (
        Customer_kategori.customerCode = Customer.customerCode
        OR 
        0 = (select count(Customer_kategori.customerCode) from Customer_kategori)
    )
    AND
    (
        ....
    )
    

    UPDATE

    How about this:

    UPDATE Customer
    SET 
        kategori = Customer_kategori.kategori,
        design = Customer_design.design,
        designCode = Customer_designCode.designCode,
        value = Customer_value.value
    
    FROM 
         Customer left join Customer_kategori on Customer_kategori.customerCode = Customer.customerCode 
         left join Customer_design on Customer_design.customerCode = Customer.customerCode 
         left join Customer_designCode on Customer_designCode.customerCode = Customer.customerCode 
         left join Customer_value on Customer_value.customerCode = Customer.customerCode
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which has several ID columns to other tables. I want
I want to update the lastlogin column value .i wrote the code like this
How do I update different columns and rows across a table? I want to
If I want to update a field with the same value. For instance, a
Often I want to add a value to a table or update the value
Possible Duplicate: Combining several database table together? I want from two database table get
What I want: Update all new commits from server with my local repository in
I want to update an erb.html page in rails with information from a webscraping
I want to update 50% of the rows in a table, randomly selected. Is
I have a MySQL table with several columns, including id and count . I

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.