Combine multiple lines into one line (from two tables / result sets)

Hello experts,

I would like to know how to combine multiple lines/records in a single record. Here are the DDL and DML to tables:

create table test_table)

client_name varchar2 (50 char),

login_time timestamp (6).

logout_time timestamp (6).

auto_type varchar2 (10 char)

)

create table root_table)

navigation_time timestamp (6).

client_name varchar2 (50 char),

VARCHAR2 (50 char) nom_du_groupe

)

Insert into test_table

values ("John", TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

Insert into test_table

values ('David', TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

insert into root_table

values (TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "invalid");

insert into root_table

values (TO_TIMESTAMP ('2013-12-05 17:14:22.333 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

insert into root_table

values (TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

insert into root_table

values (TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), "David", "invalid");

insert into root_table

values (TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'David', 'GROUP_5');

game results test_table

client_name

login_time logout_time auto_typeJohn05/12/2013 5:04:01.512000 PM05/12/2013 5:27:31.308000 PMSIMPLEDavid05/12/2013 6:33:01.308000 AM05/12/2013 6:45:01.112000 AMSIMPLE

root_table result set

navigation_time client_name GroupName
05/12/2013 5:04:01.512000 PMJohnNot valid
05/12/2013 5:14:22.333000 PMJohnGROUP_1
05/12/2013 5:27:31.308000 PMJohnGROUP_1
05/12/2013 6:33:01.308000 AMDavidNot valid
05/12/2013 6:45:01.112000 AMDavidGROUP_5

And here is the SQL code I'm writing:

Select a.customer_name, a.login_time, a.logout_time, a.auto_type, Max (b.group_name)

from test_table a, b root_table

where a.customer_name = b.customer_name

Group of a.customer_name, a.login_time, a.logout_time, a.auto_type

As the 'invalid' value is greater than the value "GROUP_1" (based on the number of letter in English), the GroupName is returned as 'invalid '. I want to bring the GroupName based on the navigation_time column in the root_table so that it always returns a valid GroupName. Please help me.

Output current:

Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

--------------------------------------------------------------------------------------------------------------------------------------------

John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     Not valid

David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     Not valid

Expected results:

Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

--------------------------------------------------------------------------------------------------------------------------------------------

John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     GROUP_1

David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     GROUP_5

Thank you!

Adding INSERT statements, current and planned outputs.

This...

SELECT client_name

login_time,

logout_time,

auto_type,

GroupName

Of

(select a.customer_name,

a.login_time,

a.logout_time,

a.auto_type,

b.group_name,

ROW_NUMBER() over (PARTITION BY a.customer_name, a.login_time, a.logout_time, a.auto_type ORDER BY b.group_name) rn

from test_table a, b root_table

where a.customer_name = b.customer_name)

WHERE rn = 1;

OUTPUT:-

=========

David DECEMBER 5, 13 06.33.01.308000000 AM DECEMBER 5, 13 06.45.01.112000000 AM SIMPLE GROUP_5
John DECEMBER 5, 13 05.04.01.512000000 PM DECEMBER 5, 13 05.27.31.308000000 PM SIMPLE GROUP_1

Thank you

Ann

Tags: Database

Similar Questions

  • How to combine multiple PDFs into one file

    How to combine multiple PDFs into one file

    Hi Marketing Haskin,

    The link mentioned by Mandeep requires you to have the Acrobat software.

    However if you purchased export them to PDF / service Acrobat.com you can select 'Combine files' on the right side and then click on the button 'Select files' to select the files you want to combine.

  • How to combine multiple PDFs into one document?

    A printer told me some time ago when I bought a few things, I can combine PDF files into one pdf. Can someone tell me how you do it, and do this with pdf that are the size of the different documents? I'm an invitation, program, cards and certificates for an awards ceremony, and wanted to know if I can combine all my pdf in a big pdf, even if they are all of different sizes.

    Thanks for any help!

    Even easier in Acrobat 9 (have nothing installed earlier to check): file > combine > merge files into a single PDF file...

    You must have a full version of Acrobat, possibly Pro, player not only.

  • How to combine multiple PDFs into one document pfd

    I opened nine PDF documents and now have a single document to nine tabs.  How to save it as a PDF of the Master file?

    Hi James Haynes,

    Please see this doc KB help to combine PDF: handset of the single PDF files | Adobe Acrobat DC tutorials

    Let us know if you need help.

    Kind regards

    Meenakshi

  • How to move photos from multiple folders into one

    Hello!

    I exported photos of iPhotos to a folder on the Mac.

    He saved every moment in different folders.

    I want to combine them all, so that all the photos are in a single folder.

    How can I combine these multiple files from multiple folders into one?

    Thank you very much for your help!

    (PS next time I will not include fracture m´by moments, but for now, how do I fix?)

    Drag and drop one folder to the other.

  • InDesign CS5 - combine multiple files into a single

    I use InDesign CS5.

    My question is how can I combine several documents into one?

    I want to create a new document. I then want to choose a bunch of documents to a folder. So I want the selected statement placed at the end of the original document one by one until all selected documents have been placed.

    From the GUI, I understand it is the goal of available > > Pages > > Pages to move. How could I do with a script?

    http://indisnip.WordPress.com/2010/08/09/moveduplicate-pages-between-documents/

  • Extraction of data from two tables without discounting

    Hi friends,

    I have a problem I want to extract data from two tables without discount in the text field when I will enter any value in a text field, then the value of corressponding must come to textfield corressponding.

    for example. There are two table A and B.
    Table A has Colunm

    S_ID number;
    C_ID Varchar2 (30);
    VARCHAR2 (4) s;

    Second table B Colunm name

    S_ID number;
    What varchar (30);
    L_Name varchar (20);

    When I enter in a text field then the c_id 101 s_id, dry, first_name and last_name should come to corressponding text without refresh fields.

    How can I do that.

    Thank you
    Maury

    You can use Ajax and there are tons of good examples out there for this purpose;
    For example [http://apex.oracle.com/pls/otn/f?p=31517:236:1876567353842241]

  • XML from the interlaced lines of two Tables?

    I'm trying to generate XML data from interlaced lines of two relational tables that have a common FK, and I can't have enough to get the concept / syntax right. for example:
    CREATE TABLE A (
      PK_A NUMBER ,
      FK     NUMBER ,
      C       VARCHAR2(100) ,
      D       VARCHAR2(100) 
    ) ;
    
    CREATE TABLE B (
      PK_B NUMBER ,
      FK     NUMBER ,
      E       VARCHAR2(100) ,
      F       VARCHAR2(100) 
    ) ;
    
    ... load some data into both tables so B always has one more row than A for the any FK ...
    
      FUNCTION Get_XML(
        FK_In IN a.fk%TYPE
      ) RETURN XMLType
      IS
        TYPE A_Table_Type IS TABLE OF a%ROWTYPE ;
        TYPE B_Table_Type IS TABLE OF b%ROWTYPE ;
        TYPE XML_Table_Type IS TABLE OF XMLType INDEX BY PLS_INTEGER ;
        my_A_Table A_Table_Type ;
        my_B_Table B_Table_Type ;
        my_XML_Table XML_Table_Type ;
        my_Return_XML XMLType ;
        t NUMBER := 0 ;  -- my_A_Table index
        x PLS_INTEGER := 1 ;  -- my_XML_Table index
      BEGIN
        SELECT * BULK COLLECT INTO my_A_Table FROM a WHERE ( fk = FK_In ) ;
        SELECT * BULK COLLECT INTO my_B_Table FROM b WHERE ( fk = FK_In ) ;
        FOR i IN 1..my_B_Table.COUNT LOOP
          SELECT XMLElement( "B" , XMLAttributes( my_B_Table(i).E AS "ID" ) )
            INTO my_XML_Table( x ) FROM dual ;
          x := x + 1 ;
          IF ( t < my_B_Table.COUNT ) THEN
            t := t + 1 ;
            SELECT XMLElement( "A" , XMLAttributes( my_A_Table(t).C AS "ID" ) )
              INTO my_XML_Table( x ) FROM dual ;
            x := x + 1 ;
          END IF ;
        END LOOP ;
        SELECT XMLAgg( SELECT * FROM TABLE( my_XML_Table ) INTO my_Return_XML FROM dual ;
        RETURN my_Return_XML ;
      END Get_XML ;
    -----

    The statement "SELECT XMLAgg (... "does not, compile with one" ORA-00936: lack the expression "error." Using an associative array of XMLType is my last attempt to build up interlaced table A / B XML fragments in a single global XML fragment. At first, I just tried to XMLConcat each query results directly in my_Return_XML.

    --
    Alex

    Hello

    I see two problems here:

    (1) lack of parentheses around SELECT it and closing XMLAgg:

    SELECT XMLAgg( ( SELECT * FROM TABLE( my_XML_Table ) ) ) INTO my_Return_XML FROM dual ;
    

    (2) you cannot use the TABLE function with a type declared for PL/SQL. You must create a SQL type and declare a collection of this type.
    Alternatively, you can use SYS. XMLSEQUENCETYPE (varray of XMLType).

    Anyway, is there a simpler approach?
    For example, using a single SELECT statement:

    SQL*Plus: Release 10.1.0.4.2 - Production on Mar. Mars 30 11:32:08 2010
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Connecté à :
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> CREATE TABLE A (
      2    PK_A NUMBER ,
      3    FK     NUMBER ,
      4    C       VARCHAR2(100) ,
      5    D       VARCHAR2(100)
      6  ) ;
    
    Table créée.
    
    SQL> CREATE TABLE B (
      2    PK_B NUMBER ,
      3    FK     NUMBER ,
      4    E       VARCHAR2(100) ,
      5    F       VARCHAR2(100)
      6  ) ;
    
    Table créée.
    
    SQL> INSERT INTO a
      2  SELECT level, '1', 'A:VALUE '||to_char(level,'fm09'), 'A:VALUE '||to_char(level,'fm09')
      3  FROM dual
      4  CONNECT BY level <= 10;
    
    10 ligne(s) créée(s).
    
    SQL> INSERT INTO b
      2  SELECT level, '1', 'B:VALUE '||to_char(level,'fm09'), 'B:VALUE '||to_char(level,'fm09')
      3  FROM dual
      4  CONNECT BY level <= 11;
    
    11 ligne(s) créée(s).
    
    SQL> commit;
    
    Validation effectuée.
    
    SQL> set long 500
    SQL> set pagesize 50
    SQL> variable fk number;
    SQL> exec :fk := 1;
    
    Procédure PL/SQL terminée avec succès.
    
    SQL> SELECT xmlagg(
      2           xmlelement(evalname(ename), xmlattributes(id)) order by rn
      3         ).extract('/*') --< for formatting purpose
      4         as xmldoc
      5  FROM (
      6    SELECT 2*rownum-1 as rn,
      7           'B'        as ename,
      8           e          as id
      9    FROM b
     10    WHERE fk = :fk
     11    UNION ALL
     12    SELECT 2*rownum,
     13           'A',
     14           c
     15    FROM a
     16    WHERE fk = :fk
     17  );
    
    XMLDOC
    --------------------------------------------------------------------------------
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    Interlacing is made in the inner query by assigning same ROWNUMs odd and table A to table B.

  • Extract single line transformed from two tables

    I have two tables T1 and T2 with the same set of columns. The columns are C1, C2, C3, COND1. I need to issue a query that returns a line transformed in order to respect the following rules:

    1. the returned line may contain values from both tables based on the values of column in table T1.

    2 return the column C1 in table T1; If it is NULL, then return to any value is present in the column C1 of T2.

    3. article 2 above apply to all columns like C1, C2 etc.

    I published the following query. The problem is that if a subquery does not reach the entire query fails. Someone help me please. Probably there is another simple method.

    SELECT NVL (T1.c1, T2.c1) c1, c2 (T1.c2, T2.c2) NVL NVL (T1.c3, T2.c3) c3

    FROM (SELECT c1, c2, c3

    FROM T1

    WHERE cond1 = 'T10') T1

    (SELECT c1, c2, c3

    THE T2

    WHERE cond1 = "T200") T2;

    Hello

    user4274403 wrote:

    I have two tables T1 and T2 with the same set of columns. The columns are C1, C2, C3, COND1. I need to issue a query that returns a line transformed in order to respect the following rules:

    1. the returned line may contain values from both tables based on the values of column in table T1.

    2 return the column C1 in table T1; If it is NULL, then return to any value is present in the column C1 of T2.

    3. article 2 above apply to all columns like C1, C2 etc.

    I published the following query. The problem is that if a subquery does not reach the entire query fails. Someone help me please. Probably there is another simple method.

    SELECT NVL (T1.c1, T2.c1) c1, c2 (T1.c2, T2.c2) NVL NVL (T1.c3, T2.c3) c3

    FROM (SELECT c1, c2, c3

    FROM T1

    WHERE cond1 = 'T10') T1

    (SELECT c1, c2, c3

    THE T2

    WHERE cond1 = "T200") T2;

    Are you saying that if there is no row in t1 that satisfy the condition cond1 = "T10", then you want to keep seeing the lines (and values) of the t2?

    And even, if there is no row in t2 that satisfy the cond1 = "T200" condition, then you want to keep seeing the lines (and values) from t1?

    If so, this looks like a job for a full outer join.

    You can change the join in a full outer join as follows:

    SELECT NVL (T1.c1, T2.c1) AS c1

    , NVL (T1.c2, T2.c2) C2

    NVL (T1.c3, T2.c3) AS c3

    FROM T1

    FULL OUTER JOIN T2 ON t1.cond1 = 'T10 '.

    AND t2.cond1 = 'T200.

    WHERE t1.cond1 = 'T10 '.

    OR t2.cond1 = "T200"

    ;

    If you would care to post CREATE TABLE and INSERT instructions for some examples of data, then I could test this.

    What happens if no table has all the lines that have good values in cond1?

  • Several lines to a format of columns from two tables

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    The difficulty to return several lines simple lines/columns in two tables.

    Table 1:

    ID BOOK_NBR
    1 1001
    1 2001
    2 1010
    3 1020

    Table 2:

    AUTHOR BOOK_NBR
    1001 JOHN_1
    2001 JOHN_2
    MARY 1010
    1020 JUNE


    Desired output:

    ID BOOK_NBR AUTHOR BOOK_NBR AUTHOR
    1 1001 JOHN_1 2001 JOHN_2
    2 MARY 1010
    3-1020 JUNE


    There are an unknown number of BOOK_NBR to one ID.

    Any guidance would be appreciated.
  • Can I combine multiple files into a PDF TIF?

    Can I combine multiple TIF files in a PDF using Acrobat DC.  I have the paid version.

    Yes, via file - create - combine files into a single PDF...

  • Combine multiple files into a single file adobe adobe - do I need to buy additional products other than the adobe reader software

    I don't seem to be able to combine multiple adobe files into a single adobe document.  Do I need to buy an additional product for this in adobe reader?

    Hi Art Brock,

    You can buy the Adobe PDF package to combine the files using Adobe Reader, if you must use Acrobat Reader DC for this task.

    You can purchase the subscription by using the following link: online PDF converter, convert to web or Acrobat Reader | Adobe PDF Pack

    Kind regards
    Rahul

  • combine multiple files into a single

    Hi all

    Request:

    1. the need to combine several files into a single

    2. the user already created destination doc

    3 folder contains about 30 files (all files having 1 page only)

    4. the need for a

    Script:

    1. to receive the forum script (combine multiple documents)

    2. using the forum script, the output comes wrongly (comes side by side)

    Fault output using the script below:

    Screen Shot 2015-05-31 at 8.05.38 PM.png

    Power required:

    Screen Shot 2015-05-31 at 8.08.48 PM.png

    Slightly modified:

    #target indesign
    // set the destination document as the active document.
    var destination_doc = app.activeDocument;
    destination_doc.documentPreferences.allowPageShuffle = true;  
    destination_doc.spreads[-1].allowPageShuffle = true;  
    
    // select the source folder
    var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files.");
    var fileList = sourceFolder.getFiles();
    fileList.sort();
    
    for ( var i = 0; i < fileList.length; i++ ) {
        var source_file = fileList[i];
        
        if ( source_file instanceof File && source_file.name.match(/\.indd$/i)) {
            app.open(source_file);
            var source_doc = app.open(source_file);  
            var sourcePages = app.activeDocument.pages.item(0);
            sourcePages.duplicate(LocationOptions.AFTER, source_doc.pages.item(0));
            sourcePages.move(LocationOptions.AFTER, destination_doc.pages.item(-1));
            app.activeDocument.close(SaveOptions.NO);
        }
    }
    

    Thanks in advance

    Siraj

    Hello

    You should duplicate/move a spread instead of a page.

    Try simply change around L18 - 20 as below.

            var source_doc = app.open(source_file);
            var sourceSpreads = app.activeDocument.spreads.item(0);
            sourceSpreads.duplicate(LocationOptions.AFTER, source_doc.spreads.item(0));
            sourceSpreads.move(LocationOptions.AFTER, destination_doc.spreads.item(-1));
            app.activeDocument.close(SaveOptions.NO);
    

    Thank you

  • Remove a line from several tables

    Hello

    I have a form that has what appears to be a single table.  Given that I needed 30 column (29 of them are single character fields) I had to use 2 objects from the table.  Then I had the ability to add and delete lines.  Add a line at the end is pretty easy.  Deleting a specific line is the problem.  For now, I added a third table that has a header line and a line of item body.  the body line is a button with the intention to withdraw this entire line of the table.  In other words, need remove the line in all 3 tables.

    My structure is:

    • Form1
      • (Some other subform past who is not serious for us)
      • SubformPersonnel (a subform sank)
        • SubformHeader (a positioned subform)
          • TextOverallHeader (text to label the oeverall 3 tables)
          • ButtonAddRow (adds a line at the end of all 3 tables)
        • SubformPersonnelTable (a positioned subform)
          • ContractorTableRemove (a table with a 1 column for the button Delete)
            • HeaderRow (line hidden to align the table with the other 2)
            • Element (a line with the button Delete)
              • CellRemoveButton (the cell with the button Delete and associated JavaScript)
          • ContractorTableLeft (a table with the left 15 printed columns)
            • HeaderRow
            • Contractor (a row of data to be deleted when it is clicked on CellButton above)
          • ContractorTableRight (a table with the right 15 printed columns)
            • HeaderRow
            • Contractor (a row of data to be deleted when it is clicked on CellButton above)
      • (Some other subforms that I'm not worried at the moment)

    The 3 tables are aligned to the headers of all line up, no space between them.  Body lines line up then and it looks like a large table.  From left to right, they are:

    ContractorTableRemove, ContractorTableLeft, ContractorTableRight

    Point lines and contractor are added when you click on ButtonAddRow in the header of all.  The initial number is set to 8 for each table, so I get 8 rows at the start. The minimum number is set to 1 for each.  I know that each row in each table has the same index number, because I filled in a cell in each table cell initialize durig.  This line, in the click event of the CellRemoveButton removes the row of the cell in this table:

    This.parent.parent._item.removeInstance (this.parent.index);

    I tried all kinds of ways to remove the same line (using the index #) in the other 2 tables: ContractorTableLeft and ContractorTableRight, but do not seem to get the correct correct syntax.  I tried hard coding references, using .parent as shown below and also tried to use an index 1 just to try deleting a line with no result.

    this.parent.parent.parent.ContractorTableLeft._Contractor.removeInstance (this.parent.inde, x);

    Can someone get me the correct syntax here?

    For example put a button Delete hidden on each table, click on that I saw, but I'm afraid it will get in the tables on each side of the table, in that it is the trail.  I reeally want just to refer to the line and remove it if I can avoid all these problems of further removal can cause problems.

    I copied the form to https://Acrobat.com/#d=7M8R50rEHf4AaVXppwyKLw

    Hi Karl,

    Here is your form you: https://acrobat.com/#d=oRRJP3W * OgBk6DqXXbJhgg.

    I've corrected the Add button, the button Delete and remove the button at the top. I annotated the script, so I hope you can follow.

    Hope that helps,

    Niall

  • Update a row based on a line from another table

    Hello

    I have two tables that have the same field, but with a different name.


    CREATE TABLE FAVE_CODE2_NEW_JOIN
    (
    VARCHAR2 (5 BYTE) BANKID NOT NULL,.
    CUSTOMERID VARCHAR2 (12-BYTE) NOT NULL,
    SIXID VARCHAR2 (12-BYTE) NOT NULL,
    FAVCODE VARCHAR2 (13 BYTE),
    IDX NUMBER (5),
    DEFAULTT NUMBER (1)
    )
    TABLESPACE PORTFOLIO_FAVORITE
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE)
    64K INITIALS
    ACCORDING TO 1 M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    DEFAULT USER_TABLES
    )
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;




    CREATE TABLE SUBSCRIPTION
    (
    SUBSCRIPTIONID RAW (16) NOT NULL,
    APPID VARCHAR2 (64 BYTE) NOT NULL,
    VARCHAR2 (64 BYTE) DEVICE ID,
    SUBSCRIBERID NUMBER NOT NULL,
    TIME_REGISTERED TIMESTAMP (6) DEFAULT SYSTIMESTAMP NOT NULL,
    TIME_LAST_USED TIMESTAMP (6) DEFAULT SYSTIMESTAMP NOT NULL,
    SUBSCRIPTION_TYPE VARCHAR2 (30 BYTE) NOT NULL,
    SUBSCRIPTION_INFO VARCHAR2 (512 BYTE)
    )
    TABLESPACE PORTFOLIO_FAVORITE
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE)
    64K INITIALS
    ACCORDING TO 1 M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    DEFAULT USER_TABLES
    )
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;



    SUBSCRIPTION_INFO in SUBSCRIPTION is equal to SIXID in FAVE_CODE2_NEW_JOIN. They have the same value

    In the FAVE_CODE2_NEW_JOIN table, there is also a class FAVCODE.
    Now, I want to know the record of VE_CODE2_NEW_JOIN that have the same sixid as SUBSCRIPTION_INFO in SUBSCRIPTION and then replace this with the value SUBSCRIPTION_INFO in FAVCODE


    Some examples of the two tables:


    SUBSCRIPTION:

    B31E5F5D3CB6 RIe9pnbe7BtA8IuQ BB2-58CA815F9958 21 2012-01-10 19:18:39 2012-01-11 12:24:04 FT FSB0650444
    010FB3AE74AE RIe9pnbe7BtA8IuQ 845-AD375E95ED90 21 2012-01-12 08:31:47 2012-01-24 08:53:09 FT FSB0650444
    6119E731A26F RIe9pnbe7BtA8IuQ 76 113 a-DAD2E359BF3F 2012-01-04 00:25:05 2012-01-19 16:17:21 FT FSB0632948


    FAVE_CODE2_NEW_JOIN:

    08999 191111111111 FSB0650444 SWB0553263 11 0

    As you can see they both the same "FSB0650368", but I want to replace this code with the FAVCODE corresponding to FAVE_CODE2_NEW_JOIN which is "SWB0553263".

    I hope you got what I mean, please tell me to explain more if you have problems to understand what I mean.

    Thanks in advance!

    / Louis

    Like this

    update subscription a
       set a.subscription_info =
           (
              select b.favcode
             from fave_code2_new_join b
            where b.sixid = a.subscription_info
           )
     where exists
           (
              select b.favcode
             from fave_code2_new_join b
            where b.sixid = a.subscription_info
           )
    

Maybe you are looking for