三表联合查询:
用电话品牌IDphone_brand.id 查询 电话型号表phone_model.phone_brand_id
得到
表phone_brand
phone_brand.id, 电话品牌ID
phone_brand.name, 品牌名
表phone_model
phone_model.phone_brand_id, =phone_brand.id 品牌ID
phone_model.phone_os_id, =操作系统ID
phone_model.model 电话型号
表soft:
soft.phone_os_id, 操作系统ID
soft.path; 下载路径;
再用phone_model.phone_os_id查询soft表得到soft.phone_os_id,soft.path;
mysql 查询:
select phone_brand.name,phone_model.model,soft.path from phone_brand join phone_model on phone_brand.id=phone_model.phone_brand_id join soft on phone_model.phone_os_id=soft.phone_os_id;
同表联合查询;
有表e_custmoer
其中e_custmoer.customer_id为该用户所属代理商的ID编号:e_customer.id
已知该代理商的account为:test ;需要查询出该代理商所属的下级account 及money
mysql 查询:
select b.id,a.customer_id,a.account,b.money from e_customer a join e_customer b on b.id=a.customer_id;