|
Posted by Om on 11/15/07 09:22
On Nov 15, 10:14 am, may_sapak1...@yahoo.com wrote:
> hi everyone. i'm new to sql server.
>
> i have 2 tables. i want to return \all rows in both tables for each
> row in table2. please refer to the following. sorry can't get my
> thoughts across clearly.
>
> thanks in advance
>
> create table table1 (
> c1 char(1),
> c2 tinyint
> )
>
> insert into table1 values ( 'A', 1 )
> insert into table1 values ( 'B', 2 )
> insert into table1 values ( 'C', 3 )
>
> create table table2 (
> c1 char(1),
> c2 tinyint
> )
>
> insert into table2 values ( 'D', 4 )
> insert into table2 values ( 'E', 5 )
>
> --return table1.*, table2.* from table1 for each row in table2
>
> /*
> table1 tabl1 table2 table2
> c1 c2 c1 c2
> A 1 D 4
> B 2 D 4
> C 3 D 4
> A 1 E 5
> B 2 E 5
> C 3 E 5
> */
This is a simple example of CROSS JOIN. You can write any of the
following query to get your output.
select * from table1,table2
or
select * from table1 cross join table2
Rgds,
Om
Navigation:
[Reply to this message]
|