如果想对多个表进行链接查询,可以采用如下sql结构:
select gc.common_id,gc.bom_id,gc.goods_state as '商品状态 0-下架 1-上架',gc.goods_name as '商品名称',gc.material_type as '物料类型',c1.category_name as '一级分类名称',c2.category_name as '二级分类名称',c3.category_name as '三级分类名称'
from goods_common gc
left join category c1
on gc.category_id_1=c1.category_id
left join category c2
on gc.category_id_2=c2.category_id
left join category c3
on gc.category_id_3=c3.category_id
where gc.common_id > 0
on 后面为链接条件,后面可以在跟上其他链接的表,where为查询条件,可以对结果集进行过滤。