How to update one column from another table

Hello

We have some sellers who are defined as employees but without employee_id for some reason any.  So I would like to update the correct number of a view of HR records.  Here is what I tried:

update of po.po_vendors x

Define employee_id = (select apps.per_people_v7 person_id y)

where y.first_name |' '|| y.last_name = x.vendor_name)

Error received: a row subquery returns more than one line.

If I use this instruction to check, I'm correct employee_id or person_id home:

Select apps.per_people_v7 person_id y, po.po_vendors x

where y.first_name |' '|| y.last_name = x.vendor_name

When I checked/compared with some old posts here, I could not just see where I did mistake.  Please notify.

Thank you

Ning

Because for the same vendor id, you have a (employee id) id of the person twice in the target table. As Boneist said "fix data, difficulty of the request, fix the requirement...". »

How many sellers are there in your target table?

Tags: Database

Similar Questions

  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • How to remove a column from a table in a dell identtiymananger 7.0

    How to remove a column from a table in a dell identtiymananger 7.0

    Hello

    In Version 7 of the removal of a single custom column can be accomplished by a stored procedure, available in the database called: QBM_PColumnDrop

    Hope that helps.

    Cordially Fatih

  • How can I insert data from another table into a table containing a timestamp column

    How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.


    I use MS SQL

    Sorry, I managed to get around this by inserting null as the value

  • How to update exists column on the table with the exact number and auto increment

    Hello

    I have a table with more than 10 million rows and there is a column called 'number_zaq', I want to update this column on line frist from 2000 and + 1 for the next all ranks.

    Update your_table

    Set number_zaq = rownum + 2000-1;

  • update of data from another table

    Hi, I would like to help. I Don t know how I can start doing:


    I have a table with a column with numbers (primary key) and I need to create another column with the same values,


    I want to change a table that has only numeric values (PK) to another
    value, so I disable the constraints of linked tables
    then I create another column that I called the "d" column and copy the values
    from column A to column D

    For example.

    TABLE XYZ

    COLUMN A: COLUMN D: (NEW)

    00001 00001
    00002-00002
    00003-00003
    00004 00004


    Can I change the values in column A and D of the column will be kept

    TABLE XYZ
    COLUMN A: COLUMN D:

    00001 99901
    99902 00002
    99903 00003
    99904-00004


    As the tables that must "point" to the column, I change the values with the new numbering

    TABLE ZZZZ

    COLUMN B: (the values of the column before the change)

    00001
    00002
    00003
    00004
    ...

    I want it like this:

    99901
    99902
    99903
    99903
    99904
    ...


    In other words, I find the current value in column D of the XYZ table for the new value that is in column a.



    I appreciate the help! :)

    Try this
    Here you will find a record in test1 for a record for each line of teste2 in teste2 joined the condition t1.numer_documento2 = t2.numero_documento.

    This is called as subquery related Co. What you were doing was under queries that and not to join the top request.

    UPDATE teste2  t2 SET NUMERO_DOCUMENTO =
    (SELECT T1.NUMERO_DOCUMENTO
      FROM teste1 t1
      WHERE t1.numer_documento2 = t2.numero_documento
      and ROWNUM = 1 )
    
    -- "Check/Select your data before you commit "
    

    SS

  • How to make one file from another user on my laptop account?

    I have a file that I backed up on my laptop but didn't know it was on my son's user account, now I don't know how to transfer them to my user account... Help

    Hello

    Logon as ADMIN, then you can access all the areas of your computer. Then copy the file to a place
    on your account such as the C:\Users\Your user documents. Once copied, then you can remove it from
    the other account.

    I hope this helps.

  • How to stop one timer from another class?

    I am trying to stop a timer in the stopwatch class MainMenu class. But my code does not work, here is my code:

    in the class MainMenu I have method:

    public function pauseGame (e:MouseEvent){

         timestop = new Stopwatch();

         timestop.Stoptimer(); }

    in the Stopwatch class, I'm trying to stop my timer with:

    public function Stoptimer(){

          timer.stop();

          timer.removeEventListener(TimerEvent.TIMER, timeFun);

          return; }

    You pass a reference to the timer to the Stoptimer class.

  • How to upgrade a minimum value of column column in another table?

    Hi all

    I created a few tables as below, and it need to update a column in a table with a minimum value of the column of another table...

    Scenarios explained as follows:
    CREATE TABLE T_20 (CONTROL NUMBER(10) NOT NULL,
                                PO NUMBER(10) NOT NULL,
                                AMENDNO NUMBER(3) NOT NULL,
                                FACTOR VARCHAR2(3) NOT NULL,
                                COMMENT_X VARCHAR2(40),
                                FLAG VARCHAR2(1))
    
    
    SQL> alter table t_20 add constraint t_20_pk primary key (control, po, amendno, factor);
    
    SQL> DESC T_20;
     Name                                      Null?    Type
     --------------------------           -------- --------------
     CONTROL                           NOT NULL NUMBER(10)
     PO                                     NOT NULL NUMBER(10)
     AMENDNO                          NOT NULL NUMBER(3)
     FACTOR                             NOT NULL VARCHAR2(3)
     COMMENT_X                                      VARCHAR2(40)
     FLAG                                                 VARCHAR2(1)
    
    Table altered.
    
    CREATE TABLE T_30 (CONTROL NUMBER(10) ,
                                PO NUMBER(10) ,
                                AMENDNO NUMBER(3) ,
                                FACTOR VARCHAR2(3) ,
                                AMOUNT NUMBER(10,2),
                              USER_NAME VARCHAR2(4))
    SQL> /
    
    Table created.
    
    SQL> INSERT INTO T_20 VALUES(101,1000,01,'MSC','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(101,1000,02,'MSC','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(101,1001,00,'NDP','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(101,1001,01,'NDP','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(102,1002,00,'ABC','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    
    SQL>  INSERT INTO T_30 VALUES(101,1000,NULL,'MSC','400','A')
      2   /
    
    1 row created.
    
    SQL>  INSERT INTO T_30 VALUES(101,1000,NULL,'MSC','500','S')
      2   /
    
    1 row created.
    
    SQL>  INSERT INTO T_30 VALUES(101,1001,NULL,'NDP','600','I')
      2   /
    
    1 row created.
    
    SQL>  INSERT INTO T_30 VALUES(101,1001,NULL,'NDP','700','R')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_30 VALUES(102,1002,NULL,'ABC','800','L')
      2  /
    
    SQL> SELECT * FROM T_20
      2  /
    
     CONTROL     PO         AMENDNO      FACTOR     COMMENT_X         F 
    ----------         ----------    ----------        --------          --------------            ---- 
     101       1000          1       MSC       NO COMMENT           Y 
     101       1000          2       MSC       NO COMMENT           Y 
     101       1001          0       NDP       NO COMMENT           Y 
     101       1001          1       NDP       NO COMMENT           Y 
     101       1002          0       ABC       NO COMMENT           Y 
    
    SQL> SELECT * FROM T_30;
    
       CONTROL         PO     AMENDNO         FAC     AMOUNT  USER                            
    ----------      ---------   ----------   ---      ----------      ----                            
           101         1000        null         MSC        400      A                               
           101         1000        null        MSC        500       S                               
           101         1001        null         NDP        600      I                               
           101         1001        null         NDP        700       R                               
           101         1002        null        ABC        800       L                               
    NOW I WANT TO UPDATE T_30 THAT LOOKS AT BELOW:

    By top T_30 initially AmendNo pass is null in T_30. Now I want to update
    column based on a minimum value of AMENDNO in the column T_20
    best way I can explain is:

    In the table T_20
    For CONTROL 101-> there are two numbers with 1000 but with different Amendno like 1, 2 in.
    and
    In the T_30 Table for CONTROL 101-> there are two IN. with 1000 but currently null. REQUIREMENT IS NOW
    THE TWO DOCUMENTS SHOULD BE UPDATED WITH MIN (AMENDNO) FOR THIS CONTROL T_20. IN THIS CASE FOR THIS CONTROL
    101 MIN (AMENDNO) IS '1' (1, 2)

    SO 101 RECORDS (BOTH) OF NOW T_30 SHOULD BE UPDATED WITH '1' AS AMENDNO

    Once again 101 now have one another IN '1001' with two different 0.1 IN. now T_30 AmendNo should be updated with min (0.1) which is
    '0'

    production is expected to be lower after update:
    SQL> SELECT * FROM T_30;
    
       CONTROL      PO              AMENDNO  FAC     AMOUNT      USER                            
    ----------       ----------   ----------      ---        ---------     ----                            
           101       1000         1          MSC        400                      A                               
           101       1000         1          MSC        500          S                               
           101       1001         0          NDP        600           I                               
           101       1001         0          NDP        700           R                               
           101       1002         0          ABC        800           L  
    Propose any query pls...

    Thanks in advance...

    I'll try level better to format the pure code in the post...

    Concerning
    Prasanth

    Try this

    update t_30 x
       set amendno = (
                       select amendno
                         from (
                                select control, po, factor, min(amendno) amendno
                                  from t_20
                              ) y
                        where x.control = y.control
                          and x.po = y.po
                          and x.factor = y.factor
                     )
     where exists (
                       select amendno
                         from (
                                select control, po, factor, min(amendno) amendno
                                  from t_20
                              ) y
                        where x.control = y.control
                          and x.po = y.po
                          and x.factor = y.factor
                 )
              
    
  • access to update only one column in the table?

    Hi all

    My need is to grant access to update only one column c1 in table t1.
    I guess I should use view, could you please give me some examples? Maybe other ideas?

    Hello

    You can grant privileges on individual columns.

    GRANT   UPDATE (c1)
    ON      t1
    TO      grantee_name;
    

    Look in the manual of the SQL GRANT language. Annoyingly, in editions recent manual, GRANT is not indexed, but it is in alphabetical order with all other instructions:
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/statements_9013.htm#i2155015

  • Populating one table from another table

    Hi Forum...

    I'm trying to populate a table from another table using CFQUERY... I have no problem with the selection of data from the original table, but need help to get the data into the new table. I use MX 6.1 and access as the database server.
    The two arrays have domain names identical to the same place, and I don't want to have to code all the column names in the selection and insert command. for example

    < cfquery name = "GetData" datasource = 'somename' >
    SELECT * FROM AssetTable1 WHERE BarCode = "123456".
    < / cfquery >

    < cfloop query = "GetData" >
    < cfquery name = "InsData" datasource = 'somename' >
    INSERT INTO AssetTable2 (xxxx...)
    VALUES ("#xxxx... #'")
    < / cfquery >
    < / cfloop >

    I hope this makes sense

    Thanks in advance

    Dave

    If your tables are identical structures and their columns are of the same type and position, and both tables are in the same database, then put everything in a single query.


    INSERT INTO AssetTable2
    SELECT *.
    OF AssetTable1
    WHERE bar code = "123456".

    If the columns were in different positions, then you should be listed explicitly in the INSERT and SELECT the parts, but you get the idea.

    INSERT INTO table1 (col1, col2)
    SELECT col1, col2
    FROM table2
    WHERE all that...

    Phil

  • Update the value of the column based on another value of the column to another table

    Hi all

    I have something very confused me and need your help.

    Having two tables A and B.

    Table A have 2 column (+ id + and desc1)

    Table B have column 2 also (+ transnum + and desc2)

    Now, I want to update the column desc2 of table B identical desc1 of table was where transnum of Table B same as the id of the table has.

    I use this SQL

    update of a2 set a2.desc2 = a1.desc1 of a2 on a2.transnum = a1.id inner join a1

    but this error occurs

    Error from line 5 in order:
    update of a2 set a2.desc2 = a1.desc1 of a2 on a2.transnum = a1.id inner join a1
    Error in the command line: 5 column: 35
    Error report:
    SQL error: ORA-00933: SQL not correctly completed command
    * 00933. 00000 - "command not properly ended SQL."
    * Question: *.

    * Action. *

    Hope someone can help me. TQ for help...
    SQL> create table a1 (id number(2),des varchar2(10));
    
    Table created.
    
    SQL> create table b1 (transnum number(2),des varchar2(10));
    
    Table created.
    
    SQL> insert into a1 values (1,'maran');
    
    1 row created.
    
    SQL> insert into b1 values (1,'ram');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> update b1 set des=(select des from a1 where b1.transnum=a1.id);
    
    1 row updated.
    
    SQL> select * from b1;
    
      TRANSNUM DES
    ---------- ----------
             1 maran
    
  • How update the column in the table based on the value selected in apex4.1

    Hi all
    I have the following tables,
    leave_type table,it has the following fields,
    1.emp_name,
    2.sick
    3.casual
    and it has the values as follows,
    emp_name                  sick             casual
    guru                           10                10
    mishra                         10                10
    leave_master table and it includes the following fields
    1.emp_name,
    2.leave_type
    3.no_of_days
    I have the form based on the table "leave_master"
    Here, the leave_type has the LOV which includes.
    sick and casual.

    When the form is filled out and clicked on the button submit,
    I need to update the column leave_type in table leave_type,
    for example,.
    if 
    emp_name:guru
    leave_type:sick
    no_of_days:3
    then I want to update the leave_type column,
    sick sick = - no_of_days for the 'guru' of name
    That is to say, ill = 10-3 = 7

    then the leave_type of the table must be,
    emp_name                       sick             casual
    guru                                 7                10
    mishra                              10               10
    someone can such me what code or method I can use?
    Thank you.

    Published by: Gurujothi on May 24, 2012 21:54

    Published by: Gurujothi on May 24, 2012 21:54

    Try something like this...

    BEGIN
    IF: PXX_LEAVE_TYPE = "Sick" THEN
    UPDATE LEAVE_TYPE
    THE PATIENT VALUE = SICK -: PXX_NO_OF_DAYS
    WHERE EMP_NAME =: PXX_EMP_NAME;
    ON THE OTHER
    UPDATE LEAVE_TYPE
    DEFINE CASUAL = CASUAL -: PXX_NO_OF_DAYS
    WHERE EMP_NAME =: PXX_EMP_NAME;
    END IF;
    COMMIT;
    END;

  • Select cursor for update: multiple columns of different tables

    Hello

    I have two tables test1 and test2. I want to udpate the column (DEPT_DSCR) from the TEST1 and TEST2 using select for update and current tables of the... with the cursor.

    I have a code drafted as follows:
    DECLARE
    v_mydept1 TEST1. TYPE % DEPT_CD;
    v_mydept2 TEST2. TYPE % DEPT_CD;
    CURSOR C1 IS SELECT TEST1. DEPT_CD, TEST2. DEPT_CD OF TEST1, TEST2 WHERE TEST1. DEPT_CD = TEST2. DEPT_CD AND TEST1. DEPT_CD IS 'AA' FOR THE UPDATE OF TEST1. DEPT_DSCR, TEST2. DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1, v_mydept2;
    WHEN EXIT C1% NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR IS "PLSQL1" WHERE CURRENT OF C1;.
    SETTING A DAY TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1.
    END LOOP;
    COMMIT;
    END;

    The code above when it is run, declares that it runs successfully. But it does not update the columns you want [DEPT_DSCR].

    It works only when we want to update one or more columns of the same table... i. e by providing these columns after ' to UPDATE THE.
    I don't know what exactly is the problem when you want to update several columns of different tables.

    Can someone help me on this?

    user12944938 wrote:
    But it's more the notion of compensation and understanding.

    See the link below:
    http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a97269/pc_06sql.htm

    See the section RESTRICTION in the link above.

    Twinkle

  • Select from another table, when the query returns no result

    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    Thank you.

    user10407139 wrote:
    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    I think you need to explain more clearly if

    -you only have a couple of "billing" columns which is empty and in this case, you want to use the columns from the table 'accounts '.

    - or you have a join with another table that doesn't return data, for example a foreign key "address_id" "billing" is zero and therefore the join to other tables 'address' will return all the data

    In the first case, you have already been provided with some examples here, how to use NVL or similar functions to achieve, even if the first post first evaluates the information of 'accounts' and if it is white using information from "billing". According to your description you need the other way around. The second post a subquery recursive useless in my opinion.

    In the latter case, you should probably use an "outer" join so that the data in your table "bills" are returned, even if the join to another table is not at all the lines.

    SELECT
    NVL(AD1.ADDRESS_ATTR1, AD2.ADDRESS_ATTR1) as ADDRESS_ATTR1,
    NVL(AD1.ADDRESS_ATTR2, AD2.ADDRESS_ATTR2) as ADDRESS_ATTR2,
    NVL(AD1.ADDRESS_STREET, AD2.ADDRESS_STREET) as ADDRESS_STREET,
    ...
    FROM accounts a
    INNER JOIN billings b
    ON a.accountid = b.accountid
    LEFT OUTER JOIN address ad1
    ON b.address_id = ad1.address_id
    INNER JOIN address ad2
    ON a.address_id = ad2.address_id;
    

    In this way you pick up the address stored in the "invoices" table, if it existed, otherwise you pick up the address assigned to the "accounts" table I used an inner for the second address join join because you said that the account always has an assigned address.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

Maybe you are looking for