ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <suresh.do...@wipro.com>
Subject RE: Using Joins
Date Wed, 19 Apr 2006 03:55:07 GMT

I am using following select query.



Select * from Emp e, Ddept dt where e.empNo = dt.empNo;

I have defined two result maps. First result map contains list of second
result map.

The data base has the following data:

Emp table:

empNo empName

1                     xxx

2                     yyy

3                     zzz

Dept table:

empNo  deptName

1                     dept-xxx-1

1           dept-xxx-2

2                     dept-yyy-1

2           dept-yyy-2

when i run the query i am getting the four results.

where i am expecting two results.  The resultMap1 should contains
resultMap2 as a list, but for every detail record

one master record is returned.

________________________________

From: Ted Schrader [mailto:tschrader@gmail.com]
Sent: Tuesday, April 18, 2006 8:34 PM
To: user-java@ibatis.apache.org
Subject: Re: Using Joins



Hi Suresh,

Give us the select statement you have right now so we can see.

In the meantime, try:

SELECT *
  FROM Employee e INNER JOIN
       Dept d ON e.empId = d.empId

Ted

On 18/04/06, suresh.dodda@wipro.com < suresh.dodda@wipro.com
<mailto:suresh.dodda@wipro.com> > wrote:
>
>           
>  
>
> I am trying find the results from the multiple tables. 
>
>   
>
> I have Employee table with empId and empname.  Dept table with empId
and deptno, dept-name  
>
> There are only two rows in master and two corresponding rows in the
detail tables. 
>
>   
>
> When I am using the Inner join I am getting the four results. Where as
I am expecting two results. Each result inturn should contains  
>
> Two detail records. 
>
>   
>
> Can you please give the query syntax to fetch the data from multiple
table using the join. 
>
>   
>
>         
>
>  The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately and destroy all copies of this message and any attachments.
> 
>  WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.
>  
>  www.wipro.com
>  




The information contained in this electronic message and any attachments to this message are
intended for the exclusive use of the addressee(s) and may contain proprietary, confidential
or privileged information. If you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and destroy all copies
of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email
and any attachments for the presence of viruses. The company accepts no liability for any
damage caused by any virus transmitted by this email.

www.wipro.com
Mime
View raw message