两个mysql语句整合在一起,怎么写?

1、select id,time,error from 1 where error>20
2、select id time,error from 2 where id = '语句1查出来的ID'

1表是总表 2表是根据ID查询的时间表

能不能把这两句融合为一句?

select id time,error from 2 where id in (select id from 1 where error>20)

假设总表是:table1,时间表是table2

 select t2.id,t2.time,t2.error from table1 as t1
left join table2 as t2 on t1.id = t2.id
where t1.error >20

这是左关联查询,将table1与table2用id关联起来,在使用error创建索引筛选
你可以修改select后的查询列