Results 1 to 4 of 4

Thread: inner join duplicate data

  1. #1
    Sharon Guest

    inner join duplicate data

    i have 2 tables not connected in any way
    but both have orderid filed (same filed).
    In one table this filed (and onther one) are keys,
    the second table dose not hace a key at all.
    The same order_id CAN repeat itself in each table.
    When i try to join the tables (some rows just in one table and some in both):
    Select tab1.name, tab1.orderid, tab2.sku
    from tab1 inner join tab2 on tab1.orderid=tab2.orderid
    The result i get is duplicate.
    each row is multiple.
    What I'm doing wrong?


  2. #2
    Mike John Guest

    inner join duplicate data (reply)

    If tab1 has 2 rows orderid 1 and tab 2 has say 5 rows for orderid2
    then you will get 10 rows. This is what you have asked it for.

    I am not sure what you really need, depends on what you are actually trying to retrieve.

    Mike John

    KnowledgePool Ltd



    ------------
    Sharon at 6/13/00 8:05:53 AM

    i have 2 tables not connected in any way
    but both have orderid filed (same filed).
    In one table this filed (and onther one) are keys,
    the second table dose not hace a key at all.
    The same order_id CAN repeat itself in each table.
    When i try to join the tables (some rows just in one table and some in both):
    Select tab1.name, tab1.orderid, tab2.sku
    from tab1 inner join tab2 on tab1.orderid=tab2.orderid
    The result i get is duplicate.
    each row is multiple.
    What I'm doing wrong?


  3. #3
    Sharon Guest

    inner join duplicate data (reply)

    First of all, Thanks Mike for helping me.

    The situation is that data from tab1 inserted into tab2 (in asp code, in my application), that mean that the same order_id/s are in the 2 tables. But
    there is a situation that order_id/s are just in tab1.
    I want to get back the order_id/s that repeat in the 2 tables.
    I can not just use select... where order_id in... statement because i need fields from both tables.
    thanks again.
    Sharon



    ------------
    Mike John at 6/13/00 8:48:19 AM

    If tab1 has 2 rows orderid 1 and tab 2 has say 5 rows for orderid2
    then you will get 10 rows. This is what you have asked it for.

    I am not sure what you really need, depends on what you are actually trying to retrieve.

    Mike John

    KnowledgePool Ltd



    ------------
    Sharon at 6/13/00 8:05:53 AM

    i have 2 tables not connected in any way
    but both have orderid filed (same filed).
    In one table this filed (and onther one) are keys,
    the second table dose not hace a key at all.
    The same order_id CAN repeat itself in each table.
    When i try to join the tables (some rows just in one table and some in both):
    Select tab1.name, tab1.orderid, tab2.sku
    from tab1 inner join tab2 on tab1.orderid=tab2.orderid
    The result i get is duplicate.
    each row is multiple.
    What I'm doing wrong?


  4. #4
    Mike John Guest

    inner join duplicate data (reply)


    Will select DISTINCT achieve it?

    Mike

    ------------
    Sharon at 6/13/00 9:10:35 AM

    First of all, Thanks Mike for helping me.

    The situation is that data from tab1 inserted into tab2 (in asp code, in my application), that mean that the same order_id/s are in the 2 tables. But
    there is a situation that order_id/s are just in tab1.
    I want to get back the order_id/s that repeat in the 2 tables.
    I can not just use select... where order_id in... statement because i need fields from both tables.
    thanks again.
    Sharon



    ------------
    Mike John at 6/13/00 8:48:19 AM

    If tab1 has 2 rows orderid 1 and tab 2 has say 5 rows for orderid2
    then you will get 10 rows. This is what you have asked it for.

    I am not sure what you really need, depends on what you are actually trying to retrieve.

    Mike John

    KnowledgePool Ltd



    ------------
    Sharon at 6/13/00 8:05:53 AM

    i have 2 tables not connected in any way
    but both have orderid filed (same filed).
    In one table this filed (and onther one) are keys,
    the second table dose not hace a key at all.
    The same order_id CAN repeat itself in each table.
    When i try to join the tables (some rows just in one table and some in both):
    Select tab1.name, tab1.orderid, tab2.sku
    from tab1 inner join tab2 on tab1.orderid=tab2.orderid
    The result i get is duplicate.
    each row is multiple.
    What I'm doing wrong?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •