Click here to Skip to main content
15,885,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

SQL
SELECT FK_PROJECT_ID FROM PROJECT_LEAD_MAPPING PLM WHERE PLM.LEADER_ID = 1 AND PLM.IS_ACTIVE = 1
UNION
SELECT FK_PROJECT_ID FROM TESTCAT_PROJECT_MAPPING TPM WHERE TPM.FK_TESTCAT_ID = 1 AND TPM.IS_ACTIVE = 1
UNION
SELECT PROJECT_ID FROM PROJECT_MEMBER PM 
WHERE (PM.START_DATE <= '2012-4-17' AND PM.END_DATE > '2012-4-17') AND PM.MEMBER_ID = 1


How to write the above query using join.

Thanks in advance
Posted
Updated 17-Apr-12 20:26pm
v2

1 solution

Hi,
From the query that you have given, I guess that you can use columns "LEADER_ID, FK_TESTCAT_ID , MEMBER_ID" for the joining conditions, because you are comparing all these column values to "1". So, by guesing this I am giving you this below query which uses inner Join. Try it out.

SQL
SELECT FROM PLM.FK_PROJECT_ID, TPM.FK_PROJECT_ID,PM.PROJECT_ID FROM   PROJECT_LEAD_MAPPING PLM 
INNER JOIN 
TESTCAT_PROJECT_MAPPING TPM ON PLM.LEADER_ID = TPM.FK_TESTCAT_ID 
INNER JOIN
PROJECT_MEMBER PM ON PM.MEMBER_ID = PLM.LEADER_ID
WHERE PLM.IS_ACTIVE = 1 AND TPM.IS_ACTIVE = 1 AND (PM.START_DATE <= '2012-4-17' AND PM.END_DATE > '2012-4-17')


This will give you values in column wise.

hope it helps.
 
Share this answer
 
Comments
bhagirathimfs 18-Apr-12 5:20am    
Thanks

but one query
is it possible to show all the records in one column.
Means all the project ids should be in one column.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900