如何检索我想用连接编写嵌套查询的数据?
我想在first_name
中显示designation
,t1
,并在project_name
col2
; }中显示t2
,end_date= (select max(end_date) from project where res_id=?)
p>
你能帮我写一下sql查询吗
select R.first_name, R.Designation, R.DOB, R.DOJ, R.Department,
R.city, p.project_name, p.start_date, p.end_date,
p.end_date+1 as next_avail_date
from resources R full JOIN project p on (r.res_id=p.res_id)
where r.u_id='&u_id';
我想根据以下查询选择项目名称
select project_name from project where end_date= (select max(end_date) from project where res_id=1);
如何在上述查询中添加它?
答案 0 :(得分:0)
您可以使用子查询作为FROM CLAUSE的视图,并以与表相同的方式连接它。尝试使用类似的东西
select R.first_name,
R.Designation,
R.DOB, R.DOJ,
R.Department,
R.city,
p.project_name,
p.start_date,
p.end_date,
p.end_date+1 as next_avail_date
from resources r, (select project_name
from project
where end_date= (select max(end_date)
from project pr
where pr.res_id=1)) p
where r.u_id='&u_id'
and r.res_id=p.res_id;