How to find common fields between two tables

Hi friends,
Is there any way to find out common fields between tables and linking the tables based on common fields.
Thanks and Regards,
Chitty.

Hi Chitty,
  Try using joins it will give the fields which are only common to both the fields.
Here s an example,
SELECT mara~matnr
       marc~werks
INTO   TABLE t_material
FROM   mara AS mara INNER JOIN marc AS marc
ON     maramatnr = marcmatnr
WHERE  mara~mtart = p_mtart.
Much Regards,
Amuktha.

Similar Messages

  • How to find structural differences between two tables?

    I want to find the difference in structure between objects in two 11g databases:
    Here I want to identify:
    tables/ Views with same columns, same datatype, precision and constraints
    Identify if the same indexes and triggers are present.
    I do not want to compare the data.
    can someone give suggestions on this please?

    my first resource for SQL Developer questions is (That) Jeff Smith: http://www.thatjeffsmith.com/archive/2012/09/sql-developer-database-diff-compare-objects-from-multiple-schemas/.

  • How to find common columns from two tables

    regards

    812809 wrote:
    regardsHi,
    Use User_tab_cols view to extract the result.
    Try
    SQL> create table test3(id number(10),name varchar2(10));
    Table created.
    SQL> create table test4(id number(20),addr varchar2(200));
    Table created.Now query user_tab_cols
    SQL> select column_name from user_tab_cols where table_name='TEST3'
      2  intersect
      3  select column_name from user_tab_cols where table_name='TEST4'
      4  /
    COLUMN_NAME
    IDHope this helps
    Regards,
    Achyut
    Ps-> Mark as Complete/Answered if it meets your requirement

  • Transaction to see common data between two tables

    Is there any transaction to see common data between two tables with out creating views.
    what is the transaction to see the link between two tables
    regards
    pavan

    Hi,
            Go to a transparent table for which you want to know the common fields, from there click the button GRAPHICS (shortcut Ctrl + Shift + F11) in the application tool bar. Then you are redirected to a list containing the tables belonging to the same group. There select whatever tables you would like to see and click COPY. A window will pop-up and will show the relationship between the fields of the tables in a flow chart format.
    see to this link also.
    Common fields b/w  tables
    Regards,
    Revathi Bhoopal.

  • Need to find the Difference between two table

    Hello ,
    I have stucked in program as below scenario:-
    I have two tables of huge data of same structure in a same schema.I need to find the difference exact values in tables.
    By using MINUS we can find the difference between two table ,i need to find the what exact difference in the there values with colunm and value at that column.
    Example TableA
    Col1 col2 col3 col4 col5.... col50
    10 ABC 2001 EE 444 TT
    40 XYZ 3002 RR 445 TT3
    80 DEF 6005 YY 446 YY8
    TableB
    Col1 col2 col3 col4 col5.... col50
    10 ABC 2001 EE 444 TT
    40 XYZ 3002 RR 445 TT3
    81 DEF 6005 Yu 447 YY8
    I need to the out put like this :-
    The Diffence between two table is
    TableA.COL1=80 TableB.Col1=81, Different
    TableA.Col4=YY TableB.col4=Yu,Different
    TableA.Col5=446TableB.col5=447,Different
    Please suggest me to write the pl/sql program for the same
    thanx in advance
    KK

    Thanx friends for all your efforts
    I have a sample code for the same,this will compare the two tables for single row in each table .
    what r the modification needed for the multiple rows of values in the two tables??
    Please suggest!!
    CREATE OR REPLACE PROCEDURE test_compare
    IS
    TYPE t_col
    IS
    TABLE OF VARCHAR2 (30)
    INDEX BY PLS_INTEGER;
    l_col t_col;
    j NUMBER := 0;
    l_sql VARCHAR2 (2000);
    col1 VARCHAR2 (30);
    col2 VARCHAR2 (30);
    val1 NUMBER;
    val2 NUMBER;
    status VARCHAR2 (30);
    CURSOR c1
    IS
    SELECT column_id, column_name
    FROM all_tab_columns
    WHERE table_name = 'TEST1';
    BEGIN
    FOR i IN c1
    LOOP
    j := j + 1;
    l_col (j) := i.column_name;
    END LOOP;
    FOR k IN 1 .. j
    LOOP
    l_sql :=
    'SELECT '
    || ''''
    || l_col (k)
    || ''''
    || ', '
    || 'TEST2.'
    || l_col (k)
    || ', '
    || ''''
    || l_col (k)
    || ''''
    || ', '
    || 'TEST1.'
    || l_col (k )
    || ', '
    || 'DECODE(TEST2.'
    || l_col (k)
    || ' -TEST1.'
    || l_col (k)
    || ', 0, ''NO CHANGE'', ''CHANGED'') FROM TEST2, TEST1';
    EXECUTE IMMEDIATE l_sql INTO col1, val1,col2, val2, status;
    IF status = 'CHANGED'
    THEN
    DBMS_OUTPUT.put_line( 'TEST2.'
    || col1
    || '='
    || val1
    || ', TEST1.'
    || col2
    || '='
    || val2
    || ', '
    || status);
    END IF;
    END LOOP;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('Error:- ' || SQLERRM);
    END;
    /

  • How to write select statement between two tables

    hi,
    i need to do comparision between two table for each records.ex:
    table1:
    regid            regno         ind
    1                 1001
    1                 1002
    1                 1003
    1                  1004
    and table2:
    regid           regno
    1               1002
    1                1005
    i need to select first row from table and loop for values in second table, if the values found first record , the record must update 'yes' to ind, if not 'No'.
    please help with this.
    thanks in advance
    raja

    Hi Raja,
      Do it like this.  loop  the first table and read the second table.
    Use where condition to satisfy the conditions.
    Or
    In your select query use joins. Like this.
    SELECT mara~matnr
           marc~werks
    INTO   TABLE t_material
    FROM   mara AS mara INNER JOIN marc AS marc
    ON     maramatnr = marcmatnr
    WHERE  mara~mtart = p_mtart.
    Instead of MARA and MARC here use your tables.
    Much Regards,
    Amuktha.

  • How to find different rows in two tables which have same schema.

    There are two tables t1 and t2, they have same schema. Table t1 includes the informtion of students last month,table t2 incude the information of the students this month. I want to find the difference of the same student between two months. What should I do and How to do?

    Look a the following example:
    Table TEST_1 TEST_2
    ID ID_TX        ID ID_TX
    1 a                   1 a
    2 b                   2 b
    4 d                   4 d
    6 f                    6 f
    7 g                   7 g
    10 j                  10 j
    10 Z                10 x --- DIFFERENT
    12 x                         --- DIFFERENT
                           20 x ---- DIFFERENT
    Query:
            Select * FROM
                 ( (SELECT '1', ID, ID_TXT FROM TEST_1 MINUS SELECT '1', ID, ID_TXT FROM TEST_2)
                  UNION
                   (SELECT '2', ID, ID_TXT FROM TEST_2 MINUS SELECT '2', ID, ID_TXT FROM TEST_1) )
            Order By ID
    RESULTS:
    '        ID ID_TXT
    1        10 Z
    2        10 x
    1        12 x
    2        20 x

  • How to get the 'link' between two tables

    hi pple
    i need to find out HOW two tables are related.
    sample tables:
    SHIPS ( HULL_ID [PK] , VESSEL_NAME, GROSS_TONNAGE )
    EQUIPMENT ( E_ID [PK] , HULL_ID [FK frm SHIPS], DESC )
    PARTS ( PART_ID [PK] , E_ID [PK, FK frm EQUIPMENT], MANUFACTURER_ID)
    --> SHIPS and PARTS are some how related thro' EQUIPMENT.
    i need to get this relationship:
    Ships --> Equipment (E_ID) --> PARTS
    currently, i can get the direct parent and child tables of a given table using:
    SELECT lpad ( ' ', 2 * ( LEVEL - 1 ) ) || table_name as Child_Tables
    FROM ALL_CONSTRAINTS
    START WITH R_CONSTRAINT_NAME in
    select constraint_name
    from all_constraints
    where table_name = '%table_name%'
    and constraint_type = 'P'
    CONNECT BY PRIOR CONSTRAINT_NAME = R_CONSTRAINT_NAME ;
    To get ALL parents:
    SELECT lpad ( ' ', 2 * ( LEVEL - 1 ) ) || table_name as Parent_Tables
    FROM ALL_CONSTRAINTS
    where owner = 'CHARTUSER'
    START WITH CONSTRAINT_NAME in
    select constraint_name
    from all_constraints
    where table_name = '%table_name%'
    and constraint_type = 'R'
    CONNECT BY PRIOR R_CONSTRAINT_NAME = CONSTRAINT_NAME ;
    what i need to do is:
    1) get children & parents of SHIPS
    2) for each element of (1), get children, parents till i get PARTS
    3) so, i will get EQUIPMENT and then, PARTS.
    this wud be very expensive. my appln is in Java and i will need to call these functions - that makes it more complex. is there any simpler way out?
    and my main problem is to find out WHAT attributes line two tables. this wudnt be a big deal if it were just simple parent-child tables. but, how do i find out the attributes that link PARTS and SHIPS table?
    any ideas? -please help.
    thanks in advance
    --$uDhA

    Dear Srikanth,
    This tables can be used once we come to know whether its a customer or vendor line item but in our case we using the GL account as reference have to knock off the entries.How we come to know that aginst the GL whether its a customer or vendor line item.. Then it should route to this table.
    Suggest me if any options are there.
    Regards,
    Balaji.c

  • Finding unmatched records between two tables

    Hi,
    Suppose there are two tables - A and B and they have a couple of common key fields.  I  want to select those records from A which do not have a matching record in B. What will be most efficient way to do that?
    Thank you.

    Hey,
    Look at this link .......... i think this may help you a bit to achieve ur requirement
    http://help.sap.com/saphelp_470/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm
    Comparing Internal Tables: -
    Internal tables can be compared with the operands that are used to compare other data objects. The most important criteria for comparing the internal table are the number of lines they contain. The larger the number of lines, the larger it is for comparisons. If the both the internal tables have same number of lines, then they are compared line by line. The operands used for comparisons are LE, LT, GE, GT, EQ, NE.
    Except for EQ, the comparison stops at the first pair of components that identifies the condition false.

  • How to use common object from two tables with out join.

    HI,
    I have two tables called A & B In A table i have the following objects
    1.weekend
    2.S1(measure)
    3.S2(measure)
    4.S3(measure)
    5.S4(measure)
    And In B table i have followning columns
    1.week end
    2.p1(measure)
    3.p2(measure)
    4.p3(measure)
    5.p4(measure)
    Now in universe i created all the measure objects i.e.s1,s2,s3,s4,p1,p2,p3,p4 A.weekend,B.weekend.
    instead of using week end two times i wnt to use only once because this is common in both table.
    if i use join between these tables i am getting values fine
    But With out join is there any thing to do in universe level to create common objects to use from both the tables..I tried using aggregate awareness but while reporting it is taking as two SQL.which is not synchronized.
    Please help me on this ...

    hi,
    Although  Weekend column is present in both tables, by creating a single Object in Universe, Universe can identify relationship with only table referenced in Object Creation.
    So, there will be no identification of relationship with other table measures.
    Obviously, you need to create 2 Weekend objects in Universe (in two classes).
    Case 1: You need not join these two tables in Universe. When you create 2 Queries in WEBI, automatcially Weekend objects are synchronized (if both are of same datatype)
    Case 2: If you join these two tables in Universe, Obviously,
    your SQL may contain Weekend from Table1, measures from Table 2
    or
    your SQL may contain Weekend from Table2, measures from Table 1
    Finally, You need to create 2 objects in Universe. But your query may contain a single Object based on Case 2.
    Regards,
    Vamsee

  • How to find varience records in two tables

    Hi,
    i have two tables like emp1, emp2
    data in emp1:
    empname empid add
    alasta 10 ca
    mark 20 nw
    chews 30 jp
    data in emp2:
    empname empid add
    alasta 10 ca
    mark 20 nw
    chews 30 jp
    burgess 45 ngm
    if u observe the above two tables data you can easily identify there is repeated data/duplicated data in both tables.
    as there any way find out using comparison same records in two tables..........
    if i write a query then i can easily understand the same data is existed in two tables
    Thanks in advance....

    >
    as there any way find out using comparison same records in two tables..........
    >
    >
    if i write a query then i can easily understand the same data is existed in two tables
    >
    So, what is your problem now?
    You can join both the tables using a simple query and get the records.
    select e1.empname, e2. empname from emp1 e1, emp2 e2 where
    e1.empname = e2.empname and e1.empid = e2.empid

  • How can i merge data between two tables and then insert to another table

    Hi ,
    Could pls help me,
    I have two tables i need to merge this tables for a single column then need to insert the records to a third table
    Ex-
    Suppose emp, dept two tables , merge this two tables for empid then insert that value to emp_dept table.
    I am using oracle 10g.
    Thanks

    Hi,
    too many values comes from the select clause. I stated you have to match the columns from the emp_dept table to the columns in the select. In my example I return all the columns of emp and dept, but I think you have only one empid column, the select for example will give 2, one empid from emp and one empid from dept. So best is to match:
    insert into emp_dept
    (column1,column2,column3,empid)
    select emp.column1, emp.column2, dept.column3, emp.empid
    from   emp, dept
    where emp.empid = dept.empidAbove is an example how you can match, so the number of columns in the insert should match with the number of columns coming from the select.
    But better for us to help you is give your definitions of emp, dept and emp_dept.
    Herald ten Dam
    htendam.wordpress.com

  • How to find the relation between that tables

    Hi,
      I have to get the data from different tables but I dont have any table relation ship. So If any body can help me to get that relation ship that will be very helpful for me.
    my tables are
    LFA1     
    LFB1
    LFC1
    RFSDO
    BSIK     
    Thanks
    Imran

    >
    SURINDER SINGH OBEROI wrote:
    > Hi,
    >
    > LFA1-LIFNR = LFB1-LIFNR = LFC1-LIFNR = BSIK- LIFNR
    > LFB1-BUKRS = LFC1-BUKRS = BSIK-BUKRS
    > LFC1-GJAHR = BSIK-GJAHR
    > LFC1-ERDAT = BSIK-AUGDT
    >
    > Cheers,
    > Surinder
    You think, you can fetch accurate data with the above mentioned linkages?
    Oh btw, the question i believe the question was How to find the relation....
    pk

  • How to find the difference between two date?

    Hi,
    I currently writing a date comparision program. Below is the idea analogy,
    Currently i need to find how many day differences between 30 July 2003 and 22 June 2004. How can i use java to code it?
    Thanks.

    there doesn't seem to be a direct way but try this:int daysBetween = 0;
    Calendar c = new GregorianCalendar(2004, Calendar.JULY, 30);
    Calendar d = new GregorianCalendar(2003, Calendar.JUNE, 22);
    while (c.get(Calendar.YEAR) != d.get(Calendar.YEAR)) {
        daysBetween += 360;
        d.add(Calendar.DAY_OF_YEAR, 360);
    daysBetween += c.get(Calendar.DAY_OF_YEAR) - d.get(Calendar.DAY_OF_YEAR);This gives the correct result of 404 (= 8 days from June 22 to June 30 + 366 days between July 1 of 2003 and 2004 + 30 days from July 1 to July 30)

  • How to find the hours between two timing

    Hai All
    I had a problem that i need to calculate a working hours
    For example
    Intime outtime
    0815 1715
    so i need to calculate a time between these two timing
    how can i do using function for 100 nos
    Regards
    Srikkanth.M

    Srikkanth.M wrote:
    Hai Man
    I think i got half a way, But the time is not coming exactly. so how can i do the same code that u have give inside a function is it possible to do a function with these three requirementThis can be done in the following way, but a function should always return a value.
    Here I have just returned a dummy value of 1.
    create or replace
    function testingFunction (<paramters if any>) return number
    as
    begin
    update testTable set (wtime,ltime,etime)=(select extract(hour from (to_date('0930','HH24:MI')-to_date('1200','HH24MI')) day to second),
    case when extract(hour from (to_date('0930','HH24:MI')-to_date('1200','HH24MI')) day to second) > 0830
    then extract(hour from (to_date('1200','HH24:MI')-to_date('0830','HH24MI')) day to second)
    else 0 end,
    case when To_number('0900') > to_number('0815') then extract(hour from (to_date('0900','HH24:MI')-to_date('0815','HH24MI')) day to second)
    else 0 end from dual);
    return 1;
    end;
    A better option would be to create a stored procedure and call that. Just like the way I have done below
    create or replace
    procedure testingprocedure (<paramters if any>)
    as
    begin
    update testTable set (wtime,ltime,etime)=(select extract(hour from (to_date('0930','HH24:MI')-to_date('1200','HH24MI')) day to second),
    case when extract(hour from (to_date('0930','HH24:MI')-to_date('1200','HH24MI')) day to second) > 0830
    then extract(hour from (to_date('1200','HH24:MI')-to_date('0830','HH24MI')) day to second)
    else 0 end,
    case when To_number('0900') > to_number('0815') then extract(hour from (to_date('0900','HH24:MI')-to_date('0815','HH24MI')) day to second)
    else 0 end from dual);
    end;
    and call the procedure
    testingprocedure(<parameters if any>);
    Naveen

Maybe you are looking for

  • How can I create a WiFi LAN with AirPort ?

    I saw somewhere a WiFi LAN (a PC with an external box) where I could put my own "Shared Folder" and see everyone's on the Lan shared data. As far as I saw, with my included AirPort, I can't do the same, but this allows me to make an html server (comp

  • How to add text to the start of the subject for email sent to  wiki mail

    When an email is sent to the group wiki email address (groupname-wiki@serverurl), I would like for the subject of the email to have \[groupname-wiki\] added to the beginning of the text. Can anyone suggest to me how to do this? What configuration fil

  • New purchases are not showing up in smart playlists

    New purchases are not showing up in smart playlists. About a week ago the smart playlists stop add newly purchase music.The smart playlists  will add items that are added the the library. Any ideas?

  • £ is being reported in Oracle reports instead of £

    Hi, £ is being reported in Oracle reports instead of £, when actually "£" is stored in the database tables. I am using Oracle Reports version 9.0.2.3.0 with encoding="UTF-8" Any idea why? Cheers, Gautam

  • SUN cluster 3.1 Agent for Siebel Server

    Hi All I dont have the CD for the Sun Cluster 3.1 agent . Please suggest me a link from where i can download the agent for Sun HA For Siebel Server, Thanks/Regards