DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Need help with query

  1. #1
    Join Date
    Jan 2001
    Posts
    230

    Question

    Hi

    I have two tables abc and xyz

    SQL> create table xyz (id number(10), name varchar2(20));

    Table created.

    SQL> create table abc (id1 number(10), name1 varchar2(20));

    Table created.

    SQL> insert into xyz values(1,'bbb');

    1 row created.

    SQL> insert into abc values(1,'aaa');

    1 row created.

    Now I want the output as following

    ID Name
    ==========
    1 bbb
    1 aaa

    Is it posible? Let me know.

    Thanks.

  2. #2
    Join Date
    Jan 2001
    Posts
    230
    Hi

    I know I can do with union .

    But, If I have inserted the raw

    insert into abc values(3,'ccc');

    I DON"T WANT result like this
    ID NAME
    -----------
    1 aaa
    1 bbb
    3 ccc

    I want the result as folloing
    ID NAME
    ----------
    1 aaa
    1 bbb

    Let me know.
    Thanks.

  3. #3
    Join Date
    Aug 2000
    Posts
    462
    ora_inf,

    Can you explain how you want to decide which rows to include in the result set.

    If your table contains:

    1 aaa
    2 bbb
    3 ccc

    How should I decide which of these rows to return? By id, name or ?

  4. #4
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    If you only want to get the rows with id = 1
    then
    select * from abc where id = 1
    union
    select * from xyz where id = 1;

    Sanjay

  5. #5
    Join Date
    Jul 2000
    Posts
    243
    if you want to join tables then:
    select a.*
    from abc a,
    xyz b
    where a.id = b.id
    union
    select b.*
    from abc a,
    xyz b
    where a.id = b.id
    shawish_sababa

    [email protected]

Posting Permissions

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


Click Here to Expand Forum to Full Width