On Monday, January 7, 2013 9:01:32 AM UTC, Lukas Eder wrote:
>
> Hello,
>
>> I would like to select all equipment by player id so select the result from 
>> the player table and then get the equipment. I tried:
>>
>>
>> String record = 
>> create.select().from(PLAYERS).join(EQUIPMENT).on(PLAYERS.ID.equal(EQUIPMENT.PLAYER_ID)).where(PLAYERS.USERNAME.equal(player.getName())).fetchOne();
>>
>>
> What you want to do is use "fetch()" instead of "fetchOne()", as you're 
> probably selecting from a one-to-many relationship. Besides, you cannot 
> assign this to "String record". You will want to assign any of the 
> following:
>
> - Record record = create.select().fetchOne();
> - Result<?> result = create.select().fetch();
>
>> However this did not work! How do I go about doing this and also how do I 
>> iterate over the equipment once I have it?
>>
>> Please consider the tutorial. It includes an iteration example:
> http://www.jooq.org/tutorial.php
>
> Cheers
> Lukas 
>

I actually found the issue as some players may not have equipment, I had to 
do join left. Sorry for the String I was actually printing out the query 
with getSQL() and didn't update it! I have another small query how do you 
get the increment id when inserting?

Reply via email to