a table are in the other table without duplicate

How to check the records in a table are in the other table without duplicate.

for example, in the tables below, the records from the Table A are in Table B1. But the B2 table has duplicate and one record is missing.
I want to know which records are not in table B, records that have two copies.
as A and B2, 1 2 is not in B2, 1 1 a 2 folders in B2

A and B1, nothing should be returned.

Table A
-----------
A1 A2
-----------
1 1
1 2
1 3
-----------

Table B1
-----------
A1 A2
-----------
1 1
1 4
1 2
1 3
2 2
-----------


Table B2
-----------
A1 A2
-----------
1 1
1 4
1 3
2 3
1 1
-----------

version is the database of Oracle 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

Thank you!!

Two standard methods to compare the tables are either to use DEFINED such as UNION, UNION operations or LESS.
Or use a FULL OUTER JOIN.

If the structure of the table is the same and that you want to compare all the columns, then set them operators are the best way.

If you want to compare only on one or more columns and want to see the other columns, then a FULL OUTER JOIN is the best way.

Here is an example

select A1, A2,
      count(distinct sourcetable) cnt_tables,
      count(sourcetable) cnt_records,
      count(case when sourcetable = 'A'  then 1 end) record_is_in_A,
      count(case when sourcetable = 'B1'  then 1 end) record_is_in_B1,
      count(case when sourcetable = 'B2'  then 1 end) record_is_in_B2
   (select 'A' sourceTable, a.* from tableA a
    union all
    select 'B1' sourceTable, b1.* from tableB1 b1
    union all
    select 'B2' sourceTable, b2.* from tableB2 b2
   )
group by A1, A2
having  count(distinct sourcetable) < count(sourcetable) ;

It is an example. It will show you the records that have duplicate data in the following tables.
If you want to display all records that are in A but not in B1, you can add a few other checks.

Published by: Sven w. on August 13, 2010 17:23

Tags: Database

Similar Questions

  • Insert values into a table from another table without duplicates

    Hello

    I have a table with a field called ID; This field has duplicate values of ID.

    Then I have an empty table B (with the same fields of the table A) and I want to insert the values of the ID (on the table) without duplicates.

    Can you help me?


    Thank you much in advance.

    Hello

    If your table has duplicate values, then you cannot add a UNIQUE constraint. In this case, you will need to use a roundabout way or remove duplicates before imposing the constraint. Hope it answers your question.

    see you soon

    VT

  • If anyone can help, I just bought a 2011 mac book pro and I use it for school and I work in education and currently I have lightroom, photoshop and adobe DC, are all the other apps I put on it?

    If anyone can help, I just bought a 2011 mac book pro and I use it for school and I work in education and currently I have lightroom, photoshop and adobe DC, are all the other apps I put on it?

    Chaka - welcome!

    What you want to do on your "new" MBP?

  • I need to disable my Creative Suite license on another computer in order to activate it on a new computer, but the old computer crashed and I can't use it. Is it possible to disable the other computer without using this computer?

    I need to disable my Creative Suite license on another computer in order to activate it on a new computer, but the old computer crashed and I can't use it. Is it possible to deactivate the license on the old computer without using it?

    you are allowed two facilities, activations, you should may not disable before activating on your new computer.

    But if you don't, contact adobe for hourly pst support by clicking here and, when available, click on "still need help," https://helpx.adobe.com/contact.html.  Ask a county of activation reset.

  • Select Insert in a table without duplicate line

    Hi guys,.

    I need to migrate the data from table A in the old schema in table B of the new scheme.
    The two tables contain exactly a similar structure.
    For example: table A have neck one and col b, table B col, col b
    The two table has applied the unique constraint on A col, col B
    Col B, col A

    now, my intention is to insert, select into table B to table A.
    If there is similar data in Table B, I want to keep the data in Table B.

    Please, how do I design the query?

    A solution would be

    insert into b (select * from a minus select * from b)
    
  • First HP - where are all the other symbols?

    I would use more symbols in my programming of the HP Premium available Greek symbols.  If they are, where they are and how can I get in the program?

    (e.g. ƒ o O ∆ ˚ ¬® oe a n • ¶ § ∞ ¢ £™)

    Thanks amigos.

    MIGS

    If they are not in the popup just press SHIFT-9, then you will need to locate them in the browser of character. (shift VARS). Since there is no 23000 + characters in the calculator, chances are they are there. :-)

  • Cannot create custom themes - change the wallpaper on the evolution of a theme the wallpaper on the other themes without apparent reason.

    Hi all

    I am trying to create a bunch of different themes, with various wallpapers and color schemes.

    I use right click on desktop-> personalization.

    At first, it seemed possible to create different themes by going to the image I want, right click on 'set as wallpaper', then enter right-click-on - desktop-> personalization, right click on the theme "non-registered" now watch the wallpapers, I just chose, then selecting "save us." This appeared to save the theme under personalization-> my themes.

    I got up to 5 different themes under "My themes" by doing this.

    But now, #5 theme, it works all of a sudden is no longer like that.

    Now, when the value a new picture as a wallpaper, it does not change only "Unsaved theme" for new wallpaper, it changes at the same time theme #5 to this wallpaper as well. When I save the new theme theme #6 and then go to change theme #5 to the wallpaper I had originally, it replaces theme #6 as well. It is impossible to change a wallpaper without changing both of them.

    I don't understand why it ehaves in this way. Why can't save just a theme and then not have to worry that it will be crushed randomly if I do something else with a completely different theme?

    Th information in this link can help you.
    http://www.maketecheasier.com/create-custom-Windows-8-themes/

  • There are all the other browsers in addition to WinRT ie10?

    I would really like the choice of another browser, anyone know of any option?

    Hello

    Welcome to the Microsoft community.

    You will be able to use only Internet Explorer 10 on Windows RT. You will not be able to install other web browsers.

    If you have additional questions on the computer, please ask your question about Windows and we will be happy to help you.

  • How to use textfiled to display a string that some characters are integrate the other font not support

    Hello world

    I try to use fonts embed on a textfield, however, embed police can only support limit glyphscharacter.

    So I was thinking is - it possible that if the police understand the character, I use this font, if not understand, I use the system default font

    as the text function on http://picmonkey.com

    If I want to use embed fonts to textfield, I need to set textFiled.embedFonts = true

    However, if I did that, the characters not included in font is not displayed, even I change textformat.font = "_without"

    So how to solve this problem?

    What did picmonkey do?

    use textFiled.embedFonts = false

  • For the other sessions to find the NLS parameters.

    Hi all
    Database server Environment Details:
    2 Node Oracle 10.2.0.4 RAC on Solaris Operating System
    Parameter in Spfile:
    nls_sort = BINARY_CI
    nls_comp = LINGUISTIC
    nls_language = AMERICAN
    Parameters in database:
    SQL> select * from nls_database_parameters;
    
    PARAMETER                      VALUE
    ------------------------------ ------------------------------------------------------------
    NLS_LANGUAGE                   AMERICAN
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               AL32UTF8
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_RDBMS_VERSION              10.2.0.4.0
    
    20 rows selected.
    Parameters at client's environment variable(Its Application sever on Windows):
    Oracle Client 10.2.0.4
    nls_sort = BINARY_CI
    nls_comp = LINGUISTIC
    Now, each index on columns of type of data characters in this database are created as function of the Index of base to support Case Insensitive search using nls_sort to BINARY_CI, as shown below.
    CREATE UNIQUE INDEX UX_NAME_BR ON ONS (NLSSORT("NAME",'nls_sort=''BINARY_CI'''),"TYPE_ID", "UNIT_NUMBER", "DOMICILE", "IS_ACTIVE", "ID")
    What worries me started when I created by mistake an index btree normal on a character column. After this error just by curiosity, I enabled index followed up on this clue, when I checked in v$ object_usage it got USED!

    So I strongly suspect that there are a few sessions connected to this database with different values of NLS instead of nls_sort = BINARY and nls_comp = LINGUISTIC...

    Sort of, I did a little test in production to confirm this, as shown below:
    PARAMETER                                          VALUE
    -------------------------------------------------- ------------------------------------------------------------
    NLS_LANGUAGE                                       AMERICAN
    NLS_TERRITORY                                      AMERICA
    NLS_CURRENCY                                       $
    NLS_ISO_CURRENCY                                   AMERICA
    NLS_NUMERIC_CHARACTERS                             .,
    NLS_CALENDAR                                       GREGORIAN
    NLS_DATE_FORMAT                                    DD-MON-RR
    NLS_DATE_LANGUAGE                                  AMERICAN
    NLS_SORT                                           BINARY
    NLS_TIME_FORMAT                                    HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT                               DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT                                 HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT                            DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY                                  $
    NLS_COMP                                           BINARY
    NLS_LENGTH_SEMANTICS                               CHAR
    NLS_NCHAR_CONV_EXCP                                FALSE
    
    17 rows selected.
    
    SQL> set autotrace traceonly exp
    SQL> select id,is_active from ons where domicile = 'US' and id = 440 and name = 'AMERICAN COMPANY';
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1171456783
    
    ---------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name           | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    ---------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                |     1 |    49 |     4   (0)| 00:00:01 |       |       |
    |   1 |  PARTITION RANGE ALL               |                |     1 |    49 |     4   (0)| 00:00:01 |     1 |     3 |
    |*  2 |   TABLE ACCESS BY LOCAL INDEX ROWID| ONS            |     1 |    49 |     4   (0)| 00:00:01 |     1 |     3 |
    |*  3 |    INDEX RANGE SCAN                | IDX_COD        |     1 |       |     4   (0)| 00:00:01 |     1 |     3 |
    ---------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("ID"=440)
       3 - access("DOMICILE"='US' AND "NAME"='AMERICAN COMPANY')
    
    SQL> alter session set nls_sort=BINARY_CI;
    
    Session altered.
    
    SQL> alter session set nls_comp=LINGUISTIC;
    
    Session altered.
    
    SQL> select * from nls_session_parameters;
    
    PARAMETER                                          VALUE
    -------------------------------------------------- ------------------------------------------------------------
    NLS_LANGUAGE                                       AMERICAN
    NLS_TERRITORY                                      AMERICA
    NLS_CURRENCY                                       $
    NLS_ISO_CURRENCY                                   AMERICA
    NLS_NUMERIC_CHARACTERS                             .,
    NLS_CALENDAR                                       GREGORIAN
    NLS_DATE_FORMAT                                    DD-MON-RR
    NLS_DATE_LANGUAGE                                  AMERICAN
    NLS_SORT                                           BINARY_CI
    NLS_TIME_FORMAT                                    HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT                               DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT                                 HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT                            DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY                                  $
    NLS_COMP                                           LINGUISTIC
    NLS_LENGTH_SEMANTICS                               CHAR
    NLS_NCHAR_CONV_EXCP                                FALSE
    
    17 rows selected.
    
    
    SQL> select id,is_active from ons where domicile = 'US' and id = 440 and name = 'AMERICAN COMPANY';
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 270874147
    
    ------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                    | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    ------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                         |     1 |    49 |     2   (0)| 00:00:01 |       |       |
    |   1 |  TABLE ACCESS BY GLOBAL INDEX ROWID| ONS                     |     1 |    49 |     2   (0)| 00:00:01 | ROWID | ROWID |
    |*  2 |   INDEX RANGE SCAN                 | UX_NAME_BR              |     1 |       |     2   (0)| 00:00:01 |       |       |
    ------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('669696E6720636F6D70
                  616E7900')  AND "ID"=440)
           filter("ID"=440 AND NLSSORT(INTERNAL_FUNCTION("DOMICILE"),'nls_sort=''BINARY_CI
                  ''')=HEXTORAW('7588700') )
    IDX_COD index is a regular btree index...

    So, how can I find which sessions have access to these indexes and find the session parameters nls level connected to this database.

    I know there is no way to find settings nls for the other sessions without tracing it...

    Kickbacks will not work me
    NLS_DATABASE_PARAMETERS
    NLS_SESSION_PARAMETERS


    Could someone help me please to find these sessions these sessions that are not level session as BINARY_CI and LANGUAGE settings

    Trigger may fail if the storage space for the trace table is full. This trigger does not use dynamic SQL code: in this perspective, it is a bit more secure.

    I don't know any other way supported to retrieve another session NLS parameters. But he can there have no documented similar to this one http://dioncho.wordpress.com/2009/07/18/spying-on-the-other-session/.

  • I'm trying to put a Transition chained between two elements placed one above the other.  I tried and I failed.

    I'm trying to put a Transition chained between two elements placed one above the other. To the left of the line that she plays in the lower clip and after the line, he played in the clip above.  Is that it can be done when the two clips are on the other? I tried and I failed. Help please.

    Also how do you call this long line like?

    Thank you.

    simply put your 'top' clip where it belongs - in the scenario

    Select the clip, Option - command - down

    the secondary has no replacement for 'tracks '...

  • What is the difference between the area and the period key based?

    Hello

    In version 4.0 of the Apex, what is the difference between the region and the point function key (button created under article)?

    Thank you
    David...

    Hi David,

    I think that they have not changed, it is always the same as in the APEX 3.2 or 3.1...

    Region of buttons is placed on the top or the bottom of the region, the option buttons are treated like any other item and are placed inside the area as the other points.

    For more details, see the APEX Application Builder User Guide.

    brgds,
    Peter

    -----
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    Work: http://www.click-click.at

  • End Insight table list includes other schema Tables (without alias)

    I noticed this problem in the last few editions, including the 3.2.09.30 latest version:

    If, say, there are User1 who is the owner of a table named TABLE1 and also a USER2 who is the owner of TABLE2 and granted select access on it to User1.

    If I have a spreadsheet where I'm logged on as User1 and I type "Select * tab" and then the list of AutoComplete overview will contain 'TABLE1' both 'TABLE2 '. If I select TABLE2, then it fills the declaration as "select * from TABLE2", that won't work because it lacks the reference of the schema. I expect that TABLE1 to appear in these circumstances.

    In other words, the list of tables for completion insight contains the name table form other schemas without a prefixed schema reference. It of basically useless and only serves the background image to the top of the list of seizure semi-automatic insight and give you a false idea of the tables/views/synonyms, which are present in the current schema.

    (Note: if I type "select * from USER2.tab" then entry list semi-automatic insight correctly contains "user2.) TABLE2', which is the behavior I expect. "USER2. TABLE2"should be there, but never just"TABLE2")


    So, is there any configuration option to turn this off, or it's just a bug?

    Published by: IvanG, Sep 17, 2012 15:50

    Published by: IvanG on 17 sept 2012 16:29, removed reference to this work properly in 3.0.04, which was incorrect.

    Buggy as 14638078; fixed

  • Problem: Build a VI to display a string in the table of the lights. Each letter must be posted in a separate table and letters must move from one table to the other in the direction from left to right.

    Hi all

    Problem: Build a VI to display a string in the table of the lights. Each letter must be posted in a separate table and letters must move from one table to the other in the direction from left to right.

    I did program mentioned above but it does not work. Can you tell me what is the problem?

    There is no error is indicated in the program. If someone knows about it please try to find solutions and help me out of this problem.

    I have attached my program with this message.

    Thank you in advance!

    (1) FOR loops are your friend here.  You can make a slight restructuring using loops, and then you will have less mess to deal with, the inner loop through tunnels of autoindexing to make it even simpler.

    (2) I would only treat the numeric values of the characters.  So go terminal of control of the chain, the capital letters and byte array to before the outer loop.  You can use a size of Board over there to tell how many times the outer loop to iterate.

    (3) the Index table is extensible.  So you only need over the index of the first, and it will increment itself, as it develops.

    (4) you need to finish the lookup table (table 3D)

  • Table of DB tools list: how to access tables that are in the different SQL database?

    Hi all

    I work on an implementation of database (SQL server) and evaluates the Toolkit OR DB for this project.

    One of the requirements is that I need access to the tables that are in two different database

    (say Table to 1 DB and Table B to 2 DB).

    Our IT guy linked table in DB1 to DB 2 and I verfied this when I use the SQL server management studio.

    When DB 2 tables is filled, table from DB1 is also there. I can also do the same thing using MS Access.

    Table A of the DB1 is available for me enven if I only connect to 2 DB.

    Here comes the problem.

    When I use DB tool list Table.vi to access DB2, it does NOT list A table in DB1. It list only the tables in

    the database (DB2) which I am connection (using DB tool opened Connection.vi with a file DSN)

    So my work around right now is to open a separate connection both DB1 and DB2. However, this approach

    obviously creates a problem when I have to access a separate database constantly in my application.

    What would be a solution to this? I have search the Forum but only to see a post that is somewhat related to

    My question. (And it was published the 2004) Maybe I need to change the code in the orignial VI (DB tool list Table.vi)?

    My computer guy told me that he has not met this scenario since he wrote code in another environment such as

    VB and others and it has always been successful in linking the different database tables.

    I hope my question is clear and healthy because I don't really know much about database terminology.

    Any comment or suggestion is appreciated!

    Thank you

    Chad

    Ok.  Here is some information that I can work with.  Good.

    Your COMPUTER staff created a view called "VISUAL_WORK_ORDER".

    A view isn't a table.  It is a "virtual" table  Views are used to collect data (usually) in several different tables.

    But I guess that the code inside the DB tool list Table.vi returns a list of tables.  Views are not the tables.  Then "VISUAL_WORK_ORDER" does not appear in the list.

    HOWEVER, this should not really matter.  The view is here!  And it can be queried like any table.  So, you can use DB tools Select Data.VI... and wire in "VISUAL_WORK_ORDER" as the name of the table.  This will return the contents of the view.  Alto!

Maybe you are looking for

  • lost iMovie app

    After updating to OS X El Capitan on my MacBook Air, I tried to update the software iMovie & seem to have lost the original iMovie app.  How do I replace it?

  • Update for Windows Vista Service Pack 1 offerred repeatedly; have installed 4 times.

    Original title: vista service pack 1 just reinstalled vista and sp1 only installs sound always on windows updates and I install it says his successful but while he appears again ive done four times now, and it is said in the history of the update I h

  • How can I connect at least 2 monitors to dv6 A1U59AV?

    I need to extend the desktop to display and work on a minimum of two documents, ideally 4 at the same time.   How can I connect at least two monitors or more for the dv6?  It has a HDMI and a VGA port. Thank you.

  • Dv6707us: BIOS download not a valid Win32 application

    I have a DV6707US with an AMD processor and 2 GB of RAM. I need to Flash the bios. I downloaded the latest and most recent versions. I started on a WinPE disk, because the laptop is not a hard drive at the moment. But the WinPE always tells me that t

  • Buy VMWare Fusion 6 yesterday

    I hope that there is some sort of grace period where a user gets the new version for free. If someone has been in this situation?