started using jooq about 10 minutes ago and having a small issue i 
currently have two tables:

CREATE TABLE `players` (`id` INT(10) NOT NULL AUTO_INCREMENT,`username` 
VARCHAR(12) NOT NULL,`password` CHAR(32) NOT NULL,`rights` TINYINT(4) NOT NULL 
DEFAULT '0',`x` SMALLINT(6) NOT NULL DEFAULT '3222',`y` SMALLINT(6) NOT NULL 
DEFAULT '3222',`z` TINYINT(4) NOT NULL DEFAULT '0',PRIMARY KEY (`id`),UNIQUE 
INDEX `username` (`username`)
)COLLATE='utf8_general_ci'ENGINE=InnoDBAUTO_INCREMENT=10;


CREATE TABLE `equipment` (`id` INT(10) NOT NULL AUTO_INCREMENT,`player_id` 
INT(10) NOT NULL DEFAULT '0',`slot` TINYINT(2) NULL DEFAULT NULL,`item` 
SMALLINT(4) NULL DEFAULT NULL,`amount` INT(10) NULL DEFAULT NULL,PRIMARY KEY 
(`id`),INDEX `player_id` (`player_id`),INDEX `id` (`id`),CONSTRAINT 
`FK_equipment_players` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON 
UPDATE NO ACTION ON DELETE NO ACTION)COLLATE='utf8_general_ci'ENGINE=InnoDB;


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();


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?





Reply via email to