locked
Output of sql commands RRS feed

  • Question

  • Hi,

         Suppose there are two tables employee and salary and a,b are two instances of tables employee and salary.There are 20 records in each table.Then what will be the result of the following query

     

    select a.*, b.* from employee a, salary  b.

    regards

    arun

     

     

    Friday, May 19, 2006 9:19 AM

Answers

  • create table a(a1 char(3), a2 char(3))
    create
    table b(b1 char(3), b2 char(3))
    insert
    into a values('a11', 'a12')
    insert
    into a values('a21', 'a22')
    insert
    into b values('b11', 'b12')
    insert
    into b values('b21', 'b22')
    select
    a.*, b.* from a, b


    a1   a2   b1   b2
    ---- ---- ---- ----
    a11  a12  b11  b12
    a21  a22  b11  b12
    a11  a12  b21  b22
    a21  a22  b21  b22

    I am sure you can extrapolate from there? its called a "cross join"

    Friday, May 19, 2006 9:45 AM

All replies

  • create table a(a1 char(3), a2 char(3))
    create
    table b(b1 char(3), b2 char(3))
    insert
    into a values('a11', 'a12')
    insert
    into a values('a21', 'a22')
    insert
    into b values('b11', 'b12')
    insert
    into b values('b21', 'b22')
    select
    a.*, b.* from a, b


    a1   a2   b1   b2
    ---- ---- ---- ----
    a11  a12  b11  b12
    a21  a22  b11  b12
    a11  a12  b21  b22
    a21  a22  b21  b22

    I am sure you can extrapolate from there? its called a "cross join"

    Friday, May 19, 2006 9:45 AM
  • hi  Blaire

     

    thanks for ur quick response.

    regards

    kapil.

     

    Friday, May 19, 2006 11:10 AM