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

  • Home
  • SEARCH
  • 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 7621457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:12:02+00:00 2026-05-31T04:12:02+00:00

Alright, so let’s say I have a database with a table named COMPANY_PARAMETERS that

  • 0

Alright, so let’s say I have a database with a table named “COMPANY_PARAMETERS” that looks something like this (the first two columns are the keys):

COMP_ID | PARAM_NAME | PARAM_VALUE
   A    | parameter 1| 10
   A    | sample_ind | Y
   B    | parameter 1| 20
   B    | sample_ind | N

I would like to insert a new parameter, let’s say parameter 2 into the table, for every company Id in the table. I do not know which company Id to expect, since any client can have any company Id they want, so one client might have company Ids 1,2,3,4 and another might have A,B,C,D, etc. We use a series of update scripts that we store on the repository any time we update the database. I’ve asked around and this is one of the rare (only) tables that is simply unique to every client, but I would like to try anyway.

I’ve been working with databases for less than a year and I don’t really know where to start with a problem like this. My guess would be to use a select statement to find all unique comp_Ids and then insert a row for every one of them.

Your help is much appreciated.

-Asaf

  • 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-31T04:12:04+00:00Added an answer on May 31, 2026 at 4:12 am
    INSERT INTO COMPANY_PARAMETERS
        (COMP_ID, PARAM_NAME)
        SELECT DISTINCT cp.COMP_ID, 'parameter 2'
            FROM COMPANY_PARAMETERS cp;
    

    If you wanted to be extra careful, you could extend the query to make sure the new parameter doesn’t already exist.

    INSERT INTO COMPANY_PARAMETERS
        (COMP_ID, PARAM_NAME)
        SELECT DISTINCT cp.COMP_ID, 'parameter 2'
            FROM COMPANY_PARAMETERS cp
            WHERE NOT EXISTS(SELECT 1
                                 FROM COMPANY_PARAMETERS cp2
                                 WHERE cp2.COMP_ID = cp.COMP_ID
                                     AND cp2.PARAM_NAME = 'parameter 2');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, let's say I have a table that looks like this: ID | DATE
Alright, let's say that I have the following markup: <div class=ticker> <p>News Item One.
Alright let me explain my situation first: I am part of an organization that
Alright. So I have a very large amount of binary data (let's say, 10GB)
[Note : I've simplified my example for clarity] Let's say that I have a
Alright, let's say I have these two tables: items with columns id, stuff item_properties
Alright everyone, Let's say i wanted to make a system that used only assembly
Alright, let's to business ... say I have a category (categoyid) '150 ', and
Alright so I have a task, that I have to let the client try
Alright, I'm having a hard time explaining this, let me know if I should

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.