Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Build Query

Author  Topic 

hernandezz
Starting Member

3 Posts

Posted - 2010-02-08 : 16:54:04
Hi guys,

I need your help.

I have 2 tables, table_A and table_B.

Fields of table_A: Task; Start_date_ID; Finish_date_ID
Fields of table_B: Date_ID; Description

I want to build a query in order to know the starting and the finishing date of a given task. However on table_A I only have one ID and on table B I only have one Date ID.

The query there I’m trying to build should be something like this:

Select Task, Description
From Table_A inner join Table_B on Table_A. Start_date_ID = Table_B. Description

How can I obtain the field Description related with the Start_date_ID and the field Finish_date_ID?

Do you have any suggestion how I could achieve this?

Many thanks in advance

Best Regards

roshana
Starting Member

31 Posts

Posted - 2010-02-09 : 01:07:09
Hi hernandezz

check the following code whether this help you or not?

select Task,Start_date_ID,[Table_B].Description as StartDiscrition, Finish_date_ID,tempfinish.desp as EndDiscrition from
[Table_A] inner join [Table_B] on Start_date_ID = Date_ID
inner join (
select Finish_date_ID EndDat,Description desp from
[Table_A] inner join [Table_B] on Finish_date_ID = Date_ID
)as tempfinish
on [Table_A].Finish_date_ID = tempfinish.EndDat

Thanks
Roshana
Go to Top of Page

hernandezz
Starting Member

3 Posts

Posted - 2010-02-10 : 05:01:06
Roshana

Works!!!

Thanks for your help!
Go to Top of Page
   

- Advertisement -