商品推荐
SELECT
*
FROM category f
left JOIN items i on (f.id = i.root_cat_id)
left JOIN items_img ii on (i.id = ii.item_id)
上述sql语句将category、items和items_img三张表关联起来,我们只需要将其参数对应即可。但是如果我们三张表出现参数名相同,我们需要换*,
f.id as rootCatId,
f.`name` as rootCatName,
f.slogan as slogan,
f.cat_image as catImage,
f.bg_color as bgColor,
i.id as itemId,
i.item_name as itemName,
ii.url as itemUrl,
i.created_time as createdTime