请教:数据库in条件中的查询语句解惑
一个sql查询语句中需用到in条件,因为条件中的id来自不同的表的集合,写了以下两个sql语句,第一种会报错,第二种可以,对此表示疑惑,代码如下:
1、select nvl(a.p_id,d.f_id)||','||nvl(b.c_id,d.f_id)||','||nvl(c.h_id,d.f_id)||','||d.f_id from t_property a, t_car b, t_human c, t_claim dwhere a.f_id(+)=d.f_ID and b.Cf_ID(+)=d.f_ID and c.f_ID(+)=d.f_ID and d.report_id='9050003202011001094';
2、 select a.p_id from t_property a,t_claim dwhere a.f_id=d.f_ID and d.report_id='9050003202011001094' union select b.c_id from t_car b,t_claim d where b.f_id=d.f_ID and report_id='9050003202011001094' union select c.h_id from t_human c,t_claim d where c.f_id=d.f_ID and d.report_id='9050003202011001094' union select f_id from t_claim d where d.report_id='9050003202011001094';