Обсуждение: regarding join
hi all,
below I have created two tables in pgsql with field name as 'name' and 'id' as their datatype 'varchar(15)' and 'integer'.
One of the table is:->
chemical=> select * from test1;
name | id
-------+----
akhil | 1
b | 2
c | 3
d | 4
e | 5
f | 6
(6 rows)
Another table is:->
chemical=> select * from test3;
name | id
------+----
ab | 1
cd | 2
ef | 3
gh | 4
(4 rows)
i want the output as:->
name | id
-------+----
akhil | 1 -----from test1 table
ab | 1------from test2 table
b | 2-----from test1 table
cd | 2------from test2 table
c | 3-----from test1 table
ef | 3------from test2 table
d | 4-----from test1 table
gh | 4------from test2 table
e | 5-----from test1 table
f | 6-----from test1 table
i have tried all the joins but it makes different fields for different tables.
is there any way out for this kind of output??????????????????
(plz reply asap)urgent.
THANKS IN ADVANCE
--
Thanks & Regards,
Akhilesh
S/W Trainee (EDP),
NUCHEM Pvt. Ltd.,
Faridabad(Haryana)
GSM:-(+919891606064)
"FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"
below I have created two tables in pgsql with field name as 'name' and 'id' as their datatype 'varchar(15)' and 'integer'.
One of the table is:->
chemical=> select * from test1;
name | id
-------+----
akhil | 1
b | 2
c | 3
d | 4
e | 5
f | 6
(6 rows)
Another table is:->
chemical=> select * from test3;
name | id
------+----
ab | 1
cd | 2
ef | 3
gh | 4
(4 rows)
i want the output as:->
name | id
-------+----
akhil | 1 -----from test1 table
ab | 1------from test2 table
b | 2-----from test1 table
cd | 2------from test2 table
c | 3-----from test1 table
ef | 3------from test2 table
d | 4-----from test1 table
gh | 4------from test2 table
e | 5-----from test1 table
f | 6-----from test1 table
i have tried all the joins but it makes different fields for different tables.
is there any way out for this kind of output??????????????????
(plz reply asap)urgent.
THANKS IN ADVANCE
--
Thanks & Regards,
Akhilesh
S/W Trainee (EDP),
NUCHEM Pvt. Ltd.,
Faridabad(Haryana)
GSM:-(+919891606064)
"FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"
On Sat, Mar 25, 2006 at 12:06:34PM +0530, AKHILESH GUPTA wrote: > hi all, > below I have created two tables in pgsql with field name as 'name' and 'id' > as their datatype 'varchar(15)' and 'integer'. <snip> Looks like: select * from test1 UNION ALL select * from test3; would be a very good start. -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them.