mysql表疑难杂症



select h4.store_id,h3.crm_id,h2.role_name,h3.user_name from basic_role_user h1,basic_role h2,sys_user h3,basic_user_store h4

where h1.role_id=h2.role_id and h1.user_id=h3.id and h3.is_delete=0 and h3.crm_id=h4.user_id
and (h2.role_id=33201 or h2.role_id=33202) and h4.store_id   in(
select
bcc.ORG_ID
from area a,  basic_crm_channel bcc,sys_user m1,basic_role_user m2,basic_role m3 ,
basic_user_store  ff where  a.id=bcc.area_num
and ff.user_id=m1.crm_id and ff.store_id=bcc.ORG_ID
and bcc.channel_type=2 and bcc.is_display=0 and bcc.STATUS_CD=1000
and bcc.CHANNEL_CLASS=10  and m1.id=m2.user_id and m2.role_id=m3.role_id
and m1.is_delete=0 and m3.role_id=22205 GROUP BY a.id
)  ;


---;


select h4.store_id,h3.crm_id,h2.role_name,h3.user_name from basic_role_user h1,basic_role h2,sys_user h3,basic_user_store h4

where h1.role_id=h2.role_id and h1.user_id=h3.id and h3.is_delete=0 and h3.crm_id=h4.user_id
and (h2.role_id=33201 or h2.role_id=33202) and h4.store_id in

( '2-Y4SQK3Q','2-S1PFC0Q','1-3EEO-49','2-THDMQDB','2-SQZX9SV','1-4ZHR-1'

,'2-QB9FJ5B','2-SQZX9TK','2-TBPMKV5','2-VHQMQL3','2-B3YY5WK','2-QZIO8PH','2-TNBXU19','2-W1JL0VS'  );


group by最后排序



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值