经典笛卡尔积SQL

本文探讨了经典的SQL笛卡尔积问题,展示了如何通过调整SQL语句避免产生笛卡尔积。具体例子涉及多条复杂的条件嵌套,通过合理重构查询条件,成功消除了不必要的数据交叉组合。
摘要由CSDN通过智能技术生成

经典笛卡尔积SQL:

下面的SQL会造成笛卡尔积:

insert into tydic.temp_0731 select a.user_id,a.province_code,b.attr_code from tydic.pline_user_tmp a,tydic.pline_attr_tmp b
where a.user_id = b.user_id
and (a.service_id = '80000009'  and b.attr_code in ('10000500',
'10000501',
'10000502',
'10000503'
)) or (a.service_id='80000026' and b.attr_code in ('10000105',
'10000112',
'10000128',
'10000129'
)) or (a.service_id='80000014' and b.attr_code in ('10000500',
'10000501',
'10000502',
'10001302'
)) or (a.service_id='80000015' and b.attr_code in ('10000501',
'10000502',
'10001302',
'10001303'
)) or (a.service_id='80000029' and b.attr_code in ('10000500',
'10000507',

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值