Click to See Complete Forum and Search --> : [RESOLVED] combind 2 queries into 1


Phill Pafford
10-19-2006, 10:43 AM
Hi all,

I have 2 select queries I need into one query

1st

SELECT Project_ID from Project_Master where Ref_No = '174';


2nd

SELECT Project_Name from project where Project_Id ='30';


now the only parameter I have is Ref_No='174', in this table there is a column named Project_ID where '30' is the value. In the Project_Name table the PK is '30' and the Project_Name='My Project'.

I need to get the Project_Name value from the project table, but the only value I have is the Ref_No from the Project_Master table.

So how do I combine the 2 statements above to get my results?
(Both statements return the values I need)

Thanks

scousesheriff
10-19-2006, 11:29 AM
Give the following a go:

select p.Project_Name
from
project p inner join Project_Master pm
on
(
p.Project_Id = pm.Project_ID
)
where pm.Ref_No = '174';

Phill Pafford
10-19-2006, 02:02 PM
Thanks, I figured it out another way


select distinct b.ref_no,e.Project_Name as pr_name from project_master b, project e where b.Project_Id=e.Project_Id;