SELECT `a`.`id` AS `id`, `a`.`name` AS `name`,
`color`.`value` AS `color`, `weight`.`value` AS `weight`
FROM `a`
LEFT JOIN `b` AS `color` ON `b`.`a_id` = `a`.`id` AND `b`.`name` = 'color'
LEFT JOIN `b` AS `weight` ON `b`.`a_id` = `a`.`id` AND `b`.`name` = 'weight'