Home » SQL & PL/SQL » SQL & PL/SQL » Query Problem: Populating more than required number of rows (DB2)
Query Problem: Populating more than required number of rows [message #311014] Thu, 03 April 2008 04:29 Go to next message
thisisnatesh
Messages: 92
Registered: March 2007
Member
Hi All,

Problem with my query. I am using equi join on T1
(with 3 records) and T2 (with 5) records.

But, when i query i am getting more than 5 records
i.e more than maximum number of records in the second table.

Note: Where T1, T2 are virtual tables i.e given alias
to select query.

This may represent like.

SQL> select t1.*,t2.* from
(
(select * from new1 where <cond> ) t1,
(select * from new2 where <cond> ) t2
)
where t1.c1=t2.c1;


Please help me in this regard

Thanks in Advance
Natesh
Re: Query Problem: Populating more than required number of rows [message #311017 is a reply to message #311014] Thu, 03 April 2008 04:34 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Post your Data in T1 and T2.

How the hell we know without looking into the data??
Re: Query Problem: Populating more than required number of rows [message #311019 is a reply to message #311014] Thu, 03 April 2008 04:35 Go to previous messageGo to next message
sispk6
Messages: 164
Registered: November 2006
Location: pakistan
Senior Member
please post the test case ,
we cannot tell you from this code that you wrote.
Is C1 , primary key in t1 , and foreign key in the other in your example????
Imtiaz
Re: Query Problem: Populating more than required number of rows [message #311142 is a reply to message #311014] Thu, 03 April 2008 09:51 Go to previous message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Quote:
This may represent like.

SQL> l
  1  select * from
  2  ((select * from cat) t1, (select * from tab) t2)
  3* where t1.table_name = t2.tname;
SQL> /
((select * from cat) t1, (select * from tab) t2)
                       *
ERROR at line 2:
ORA-00907: missing right parenthesis


I don't think so your code is correct.

Regards

Raj
Previous Topic: How to use DBMS_Stats
Next Topic: I want simple example of UTL_FILE package
Goto Forum:
  


Current Time: Mon Dec 05 20:59:41 CST 2016

Total time taken to generate the page: 0.24435 seconds