You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by xianwinwin <xi...@gmail.com> on 2007/10/12 19:10:24 UTC

how to write selectByExample and get info from 2 tables?

Hi all,

given the following 2 trivial tables: 
1 - user (user_id, fname, lname)
2 - messages (message_id, user_id,  user_message)

I wonder if it is possible to use selectByExample and get:

user_message, fname, lname 

As you can see, this is a combination of 2 tables. 

Is this doable???, if not, what other alternative exists beside writing the
queries (gee, that will take such a long time)

thanks 
xww
-- 
View this message in context: http://www.nabble.com/how-to-write-selectByExample-and-get-info-from-2-tables--tf4614193.html#a13177049
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: how to write selectByExample and get info from 2 tables?

Posted by Jeff Butler <je...@gmail.com>.
Abator won't write queries that join tables, so you would have to write this
by hand.

Or, you could define a view that joined the two tables and then use Abator
to generate code from the view.  That would be pretty simple.

Jeff Butler


On 10/12/07, xianwinwin <xi...@gmail.com> wrote:
>
>
> Hi all,
>
> given the following 2 trivial tables:
> 1 - user (user_id, fname, lname)
> 2 - messages (message_id, user_id,  user_message)
>
> I wonder if it is possible to use selectByExample and get:
>
> user_message, fname, lname
>
> As you can see, this is a combination of 2 tables.
>
> Is this doable???, if not, what other alternative exists beside writing
> the
> queries (gee, that will take such a long time)
>
> thanks
> xww
> --
> View this message in context:
> http://www.nabble.com/how-to-write-selectByExample-and-get-info-from-2-tables--tf4614193.html#a13177049
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>