在下面的sql里,表(ins_incident)中没有字段(process_def_start_date).可执行时没报错,是什么原因啊with main as( select distinct
incident_id,
instance_id,
instance_state,
allocate_party_id,
complete_party_id,
case when complete_party_id is null then allocate_party_id
else complete_party_id
end as partyId,
allocated_date,
activity_id,
instance_start_date
from ins_instance it
where incident_id = '20100601001'
order by instance_start_date desc,instance_id desc
)
select distinct
m.*,
u.user_name,
a.activity_name
from main m inner
join mst_user u
on u.party_id = m.partyId
and u.start_date =
(select max(start_date)
from mst_user
where party_id = u.party_id
and start_date <= '2010-06-02 15:05:24.219'
)
and u.delete_flag = false
join def_activity a
on a.activity_id = m.activity_id
and a.process_id =
(select process_id
from ins_incident
where incident_id = m.incident_id
and delete_flag = false
)
and a.process_def_start_date =
(select process_def_start_date
from ins_incident
where incident_id = m.incident_id
and delete_flag = false
)
order by instance_start_date desc,instance_id desc
incident_id,
instance_id,
instance_state,
allocate_party_id,
complete_party_id,
case when complete_party_id is null then allocate_party_id
else complete_party_id
end as partyId,
allocated_date,
activity_id,
instance_start_date
from ins_instance it
where incident_id = '20100601001'
order by instance_start_date desc,instance_id desc
)
select distinct
m.*,
u.user_name,
a.activity_name
from main m inner
join mst_user u
on u.party_id = m.partyId
and u.start_date =
(select max(start_date)
from mst_user
where party_id = u.party_id
and start_date <= '2010-06-02 15:05:24.219'
)
and u.delete_flag = false
join def_activity a
on a.activity_id = m.activity_id
and a.process_id =
(select process_id
from ins_incident
where incident_id = m.incident_id
and delete_flag = false
)
and a.process_def_start_date =
(select process_def_start_date
from ins_incident
where incident_id = m.incident_id
and delete_flag = false
)
order by instance_start_date desc,instance_id desc
解决方案 »
- MySQL海量数据插入,导致服务器性能下降,怎么处理,急急急
- mysql 数据还原出现乱吗问题 跪求!!!在线等!
- c++调用mysql存储过程问题
- 使用游标出现 No data - zero rows fetched, selected, or processed
- 查询问题 这种字符串怎么匹配啊
- 在mysql存储过程中如何创建Tempoary表
- 大家用什么mysql管理器?
- 除了MYODBC可以连接MYSQL外还有没有其他方法可以连啊?
- win98下的MYSQL的问题
- 在MYSQL中,视图中增加了一个distinct导致执行计划不先走where 条件
- linux crontab定时执行mysql的问题
- mysql安装一个很奇怪的问题 大家进来看看,帮忙解决哈
show create table ins_incident看看
select t.process_def_start_date
from ins_incident t
或者你把and a.process_def_start_date =
(select process_def_start_date
from ins_incident
where incident_id = m.incident_id
and delete_flag = false
)
之前的条件满足的数据添加上,再执行到这块时,估计会出错了。
(select process_def_start_date
from ins_incident
where incident_id = m.incident_id
and delete_flag = false
)
子查询的select可以检索外面的表(联合查询的表)的字段
process_def_start_date就是a表的字段