select *
FROM A a
WHERE a.update_time >= '20160101' and a.status_code is not null
and not exists (select 1 from (select 1 from E e where e.id = a.id order by e.update_time desc limit 1) t where e.status_code = a.status_code)
多一层子查询会发现找不到a.id,求教。
...全文
31510打赏收藏
请求一个子查询的问题
select * FROM A a WHERE a.update_time >= '20160101' and a.status_code is not null and not exists (select 1 from (select 1 from E e where e.id = a.id order by e.update_time desc limit 1) t where e.status_code = a.status_code) 多一层子查询会发现找不到a.id,求教。
select *
FROM A a
WHERE a.update_time >= '20160101' and a.status_code is not null
and not exists (select 1 from E e where e.id = a.id and e.status_code = a.status_code order by e.update_time desc limit 1)
select *
FROM A a
WHERE a.update_time >= '20160101' and a.status_code is not null
and not exists (select 1 from (select status_code from E e where e.id = a.id order by e.update_time desc limit 1) t where t.status_code = a.status_code)