Results 1 to 9 of 9

Thread: Select clause

  1. #1
    Join Date
    Jan 2004
    Location
    pakistan
    Posts
    5

    Unanswered: Select clause

    Hi,
    I there some way in which i can select from two tables simultaneously that have no common columns .
    ie I have tables A and table B (Both have the same number of records)
    I want to select all the records from table A frist , then the records from table B ..something like this :

    A B
    name telno deptno location
    xyz 534523 1 afadsf
    abc 876776 2 sfasdkfa


    so on...

  2. #2
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    Hi

    SELECT a.name, a.telno, b.deptno, b.location from a,b ;

  3. #3
    Join Date
    Jan 2004
    Location
    pakistan
    Posts
    5

    Thumbs up

    thanx for your reply.

    But i dont know the columns of the particular tables.
    I wanna select * from both tables.

    Any more suggestions?
    thanx.

  4. #4
    Join Date
    Jan 2004
    Posts
    153
    U can try out with this :


    Select * from a,b

  5. #5
    Join Date
    Jan 2004
    Location
    pakistan
    Posts
    5
    Yeah but the problem is that it will give me the cartesian product ..ie if there are 15 recs in A and 15 in B then it will return me 225 records...
    Which is not what I am looking for ...

  6. #6
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    Hi

    tell me exactly what do u expecting result from two tables.

  7. #7
    Join Date
    Jan 2004
    Location
    pakistan
    Posts
    5
    I have clearly explained but here goes again ..I want concatenatoin ie
    I have 2 recs in table A as follows :

    Field1 Field2
    ========
    1 abc
    2 xyz

    I have 2 records in table B as follows :
    Field1 Fiel2 Field3
    ===========
    x 5675 222
    a 9789 998

    I want my output as(there are no common fields in A&B)
    =============
    1 abc x 5675 222
    2 xyz a 9789 998

  8. #8
    Join Date
    Mar 2004
    Location
    Sydney
    Posts
    20
    What you are asking for does not seem to make sense but hey. The only way I think it can be done is to create and populate a surogate key in each table and then join on that key.

    eg create a column in each table called line_num which should be unique. Populated them from 1 to x. Then write a query to join the 2 tables on line_num (a.line_num = b.line_num).

  9. #9
    Join Date
    Mar 2004
    Posts
    14

    Talking Re: Select clause

    I have fun solution for this problem :
    select * from ( select rownum id_a , id from items order by id desc ) a , ( select rownum id_b , id from items2 ) b
    where id_a = id_b

    just add (+) if count of rows in not equal

Posting Permissions

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