我的SQL语句出现很奇怪的问题!请您帮忙解答!
语句如下
红色的部分是个子查询,能够正确的查询出结果,但是整条语句运行起来就陷入了漫长的等待
select t1.msisdn,t1.state,t1.suspend_date,t1.customer_name,t1.sex,t1.deal_code,t1.start_date,t1.end_date
from (select gsm_user_yz.msisdn,gsm_user_yz.state,gsm_user_yz.suspend_date,p_customer_yz.customer_name,
p_customer_yz.sex,user_smscall_yz.deal_code,user_smscall_yz.start_date,user_smscall_yz.end_date
from yzzw.gsm_user_yz,yzzw.p_customer_yz,yzzw.user_smscall_yz
where yzzw.gsm_user_yz.customer_id = p_customer_yz.customer_id and
yzzw.gsm_user_yz.gsm_user_id = user_smscall_yz.gsm_user_id and
user_smscall_yz.deal_code = '5026' and
yzzw.gsm_user_yz.msisdn in(139527...,138527...))t1
inner join
(select t.msisdn,max(t.start_date) start_date
from (select gsm_user_yz.msisdn,gsm_user_yz.state,gsm_user_yz.suspend_date,p_customer_yz.customer_name,
p_customer_yz.sex,user_smscall_yz.deal_code,user_smscall_yz.start_date,user_smscall_yz.end_date
from yzzw.gsm_user_yz,yzzw.p_customer_yz,yzzw.user_smscall_yz
where yzzw.gsm_user_yz.customer_id = p_customer_yz.customer_id
and yzzw.gsm_user_yz.gsm_user_id = user_smscall_yz.gsm_user_id
and user_smscall_yz.deal_code = '5026'
and yzzw.gsm_user_yz.msisdn in(139527...,138527...)) t group by t.msisdn ) t2
on t1.msisdn = t2.msisdn and t1.start_date = t2.start_date
这里换成直接的内容速度很快,毫秒级的!
不知道为什么会出现这样的情况!
select t1.msisdn,t1.state,t1.suspend_date,t1.customer_name,t1.sex,t1.deal_code,t1.start_date,t1.end_date
from (select gsm_user_yz.msisdn,gsm_user_yz.state,gsm_user_yz.suspend_date,p_customer_yz.customer_name,
p_customer_yz.sex,user_smscall_yz.deal_code,user_smscall_yz.start_date,user_smscall_yz.end_date
from yzzw.gsm_user_yz,yzzw.p_customer_yz,yzzw.user_smscall_yz
where yzzw.gsm_user_yz.customer_id = p_customer_yz.customer_id and
yzzw.gsm_user_yz.gsm_user_id = user_smscall_yz.gsm_user_id and
user_smscall_yz.deal_code = '5026' and
yzzw.gsm_user_yz.msisdn in(select msisdn from YZYD_GWB_MSISDNTEMP))t1
inner join
(select t.msisdn,max(t.start_date) start_date
from (select gsm_user_yz.msisdn,gsm_user_yz.state,gsm_user_yz.suspend_date,p_customer_yz.customer_name,
p_customer_yz.sex,user_smscall_yz.deal_code,user_smscall_yz.start_date,user_smscall_yz.end_date
from yzzw.gsm_user_yz,yzzw.p_customer_yz,yzzw.user_smscall_yz
where yzzw.gsm_user_yz.customer_id = p_customer_yz.customer_id
and yzzw.gsm_user_yz.gsm_user_id = user_smscall_yz.gsm_user_id
and user_smscall_yz.deal_code = '5026'
and yzzw.gsm_user_yz.msisdn in(select msisdn from YZYD_GWB_MSISDNTEMP)) t group by t.msisdn ) t2
on t1.msisdn = t2.msisdn and t1.start_date = t2.start_date红色的部分是个子查询,能够正确的查询出结果,但是整条语句运行起来就陷入了漫长的等待
select t1.msisdn,t1.state,t1.suspend_date,t1.customer_name,t1.sex,t1.deal_code,t1.start_date,t1.end_date
from (select gsm_user_yz.msisdn,gsm_user_yz.state,gsm_user_yz.suspend_date,p_customer_yz.customer_name,
p_customer_yz.sex,user_smscall_yz.deal_code,user_smscall_yz.start_date,user_smscall_yz.end_date
from yzzw.gsm_user_yz,yzzw.p_customer_yz,yzzw.user_smscall_yz
where yzzw.gsm_user_yz.customer_id = p_customer_yz.customer_id and
yzzw.gsm_user_yz.gsm_user_id = user_smscall_yz.gsm_user_id and
user_smscall_yz.deal_code = '5026' and
yzzw.gsm_user_yz.msisdn in(139527...,138527...))t1
inner join
(select t.msisdn,max(t.start_date) start_date
from (select gsm_user_yz.msisdn,gsm_user_yz.state,gsm_user_yz.suspend_date,p_customer_yz.customer_name,
p_customer_yz.sex,user_smscall_yz.deal_code,user_smscall_yz.start_date,user_smscall_yz.end_date
from yzzw.gsm_user_yz,yzzw.p_customer_yz,yzzw.user_smscall_yz
where yzzw.gsm_user_yz.customer_id = p_customer_yz.customer_id
and yzzw.gsm_user_yz.gsm_user_id = user_smscall_yz.gsm_user_id
and user_smscall_yz.deal_code = '5026'
and yzzw.gsm_user_yz.msisdn in(139527...,138527...)) t group by t.msisdn ) t2
on t1.msisdn = t2.msisdn and t1.start_date = t2.start_date
这里换成直接的内容速度很快,毫秒级的!
不知道为什么会出现这样的情况!
...全文
相关推荐
解决在SQL脚本中的注释引起的奇怪问题
通过osql.exe这个工具来对相关的数据库脚本进行更新,昨天突然发现安装包报错了,说脚本错误,研究发现有个不错的解决方法,需要的朋友不要错过
SQL Server上的一个奇怪的Deadlock及其分析方法
SQL Server上的一个奇怪的Deadlock及其分析方法
sql语句的内联外联 经典面试题
sql语句的内联外联 查询 集合 经典面试题 值得收藏 大家珍惜哦
奇怪的SQL_可以进一步跟进.
一个奇怪的sql.运行环境:vs2013的工具"connect to database"下的query window.效果:空白字符导致查询条件无效. 需要使用抓包工具进一步分析.
php实现解析xml并生成sql语句的方法
主要介绍了php实现解析xml并生成sql语句的方法,涉及php针对xml格式文件的读取、解析及sql字符串拼接相关操作技巧,需要的朋友可以参考下


