I created 3 different tables, and for him it is
CREATE TABLE `shirt` ( `id` int(11) not null, `name` varchar(32), PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `shirt` (`id`, `name`) VALUES ('1', 'vneck'), ('2', 'scoop neck'); CREATE TABLE `shirt_size` ( `shirtId` int(11) not null, `sizeId` int(11) not null, PRIMARY KEY (`shirtId`,`sizeId`), KEY `sizeId` (`sizeId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `shirt_size` (`shirtId`, `sizeId`) VALUES ('1', '2'), ('1', '3'), ('1', '4'), ('1', '5'), ('2', '1'), ('2', '2'), ('2', '3'), ('2', '4'), ('2', '5'), ('2', '6'), ('2', '7'); CREATE TABLE `size` ( `id` int(11) not null, `name` varchar(4), PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `size` (`id`, `name`) VALUES ('1', 'xs'), ('2', 's'), ('3', 'm'), ('4', 'l'), ('5', '1x'), ('6', '2x'), ('7', '3x');
and I request it with
SELECT shirt.name, size.name FROM shirt INNER JOIN shirt_size ON shirt_size.shirtId = shirt.id INNER JOIN size ON size.id = shirt_size.sizeId
but in a table that only shows the name of the shirt, I need a size column to display on the screen too. In the FROM part, I put shirt, size , but I got an error. Looking further, I saw that many people only put the first name of the table in the FROM part. I do not see how it should represent the column size.name . What am I doing wrong?