Home » SQL & PL/SQL » SQL & PL/SQL » help me urgent
help me urgent [message #21668] Wed, 21 August 2002 20:15 Go to next message
sha
Messages: 84
Registered: July 2002
Member
Hi,
If I want to retrieve rows from two tables eliminating duplicate values.
I have to retrieve the table name from tab table and the corresponding values of that table in another table.I am getting duplicate values,even I used distinct command.
e.g.
If I want to retreive the employees information where I ahve to count the number of records.
select distinct a.tname,b.deptno,count(b.ename) from tab a,emp b where a.tname like '%EM%' group by b.deptno,a.tname
thanx in advance
Re: help me urgent [message #21673 is a reply to message #21668] Thu, 22 August 2002 02:10 Go to previous messageGo to next message
AK
Messages: 7
Registered: July 2001
Junior Member
What is the foreign key in betw these tables?
Re: help me urgent [message #21714 is a reply to message #21668] Sun, 25 August 2002 07:09 Go to previous message
Su
Messages: 154
Registered: April 2002
Senior Member
First of all, your query does not work as it is not related and there is no join relation. Tab is a view which shows the list of tables existing in your schema and the one you want to retrieve employee information from is either a physical data table (called EMPLOYEE etc) or a view created on it. Since there is no link and join criteria, it gives you a cartesian product which shows the rows repeatedly.
A question, why are you comparing both these tables any way?

Check it out.

Good luck :)
Previous Topic: Installation problem
Next Topic: Multiple rows from a single row
Goto Forum:
  


Current Time: Fri Apr 26 13:30:21 CDT 2024