mysql 高级用法

三表联合查询:

用电话品牌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;




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值