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
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Query joining multiple tables need help

Author  Topic 

Ravius
Starting Member

13 Posts

Posted - 2010-05-03 : 04:15:50
Hi guys, i am new in programming.

i am currently working doing a school project that requires a function to display data from multiple tables. Can anyone help me with it? thanks in advance.

The tables are shown below:

GUESTS
(ID, name, email, contactNo, Session1ID, Session2ID, Session3ID)

SESSION
(SessionID, DateID, TimeID

DATE
(DateID, DateSelected (as in actual date in string e.g 10th may 2010))

TIME
(TimeID, TimeSelected (as in actual time in string e.g 10:00AM))

I need to select Guest.name, email, contactNo, Session1 (DateSelected and TimeSelected), Session2 (DateSelected and TimeSelected), Session3 (DateSelected and TimeSelected)

Is it possible to do that?

sakthi
Starting Member

2 Posts

Posted - 2010-05-03 : 09:16:34
Try this,

Select G.Email,g.name,(D.DateSelected+ T.TimeSelected) AS [session] From dbo.Guest G
Inner Join dbo.[session] S On G.session2ID = S.SessionId
Inner Join dbo.[Time] T on T.TimeId = S.TimeId
Inner Join dbo.[Date] D on D.DateId = S.DateId
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-03 : 10:00:32
you need to join to Date and Time separately to get each session's date times

Select G.Email,g.name,(D1.DateSelected+ T1.TimeSelected) AS [session1],
(D2.DateSelected+ T2.TimeSelected) AS [session2],
(D3.DateSelected+ T3.TimeSelected) AS [session3]
From dbo.Guest G
Inner Join dbo.[session] S1 On G.session1ID = S1.SessionId
Inner Join dbo.[Time] T1 on T1.TimeId = S1.TimeId
Inner Join dbo.[Date] D1 on D1.DateId = S1.DateId
Inner Join dbo.[session] S2 On G.session2ID = S2.SessionId
Inner Join dbo.[Time] T2 on T2.TimeId = S2.TimeId
Inner Join dbo.[Date] D2 on D2.DateId = S2.DateId
Inner Join dbo.[session] S3 On G.session3ID = S3.SessionId
Inner Join dbo.[Time] T3 on T1.TimeId = S3.TimeId
Inner Join dbo.[Date] D3 on D1.DateId = S3.DateId


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rinky30
Starting Member

5 Posts

Posted - 2010-05-03 : 13:58:56
Hi!
I have to show different two tables data having same columns in a griedview in asp.net and then export that to excel sheet.
Actually my data in two types of call schemes by mobile cmompany like (request and complain) and each category have different
sub-category. In final output i have to show each day data of both type as well as monthly updated data in same griedview such that each new day data automatically shown in new columns with its sub-columns. can i show it in griedview or i should use samething else. i have to use asp.net .
i have two final table wich have columns(Date,ATAT,WTAT,TotalClose,Percentage,Sub_Category)And tables name are tblComplain and tblRequest.. How can i show each day data as well as monthly updated data in final output. in final output. there are one column for sub Category and others columns for each day of a month in which there are 3 sub columns..
plz give me any help...

rinkySingh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 04:17:39
Dont hijack threads. please post as a new thread giving sample data and expected o/p

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rinky30
Starting Member

5 Posts

Posted - 2010-05-04 : 13:07:25
Hi Vikash
In my project i have to import a excel sheet data in sql server. From that imported data i create two tables named
tblRequest(MSISDN,CURRENTUSER,SUB_CATEGORY,STATUS,TAT,CIRCLE) and tblComplain(MSISDN,CURRENTUSER,SUB_CATEGORY,STATUS,TAT,CIRCLE)
in these two tables data are releted to call schemes of request and complain type.then from each table i created views to show final output . but i have to create all the above for each day data. How can do all this using asp.net(c#). The output is a report
within the first column is sub category name for complain then request then next column is MTD(Monthly Transaction Data) with sub columns (TotalClose,ATAT,WTAT,Pcercentage),Then there are 30-31 columns for each day data. And MTD should be updated according to each day data. I have a final output data in excel sheet. How can all the above process would i do in asp.net such that my output
come as required

rinkySingh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 13:17:15
quote:
Originally posted by rinky30

Hi Vikash
In my project i have to import a excel sheet data in sql server. From that imported data i create two tables named
tblRequest(MSISDN,CURRENTUSER,SUB_CATEGORY,STATUS,TAT,CIRCLE) and tblComplain(MSISDN,CURRENTUSER,SUB_CATEGORY,STATUS,TAT,CIRCLE)
in these two tables data are releted to call schemes of request and complain type.then from each table i created views to show final output . but i have to create all the above for each day data. How can do all this using asp.net(c#). The output is a report
within the first column is sub category name for complain then request then next column is MTD(Monthly Transaction Data) with sub columns (TotalClose,ATAT,WTAT,Pcercentage),Then there are 30-31 columns for each day data. And MTD should be updated according to each day data. I have a final output data in excel sheet. How can all the above process would i do in asp.net such that my output
come as required

rinkySingh


Please post as a new thread to improve visibility

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rinky30
Starting Member

5 Posts

Posted - 2010-05-04 : 20:01:35
Hi Vikash !
I didnot understand what do u wanna to ask about it.plz give an example of how can i show monthly as well as daily data from two tables having same column fields but row values in a gried in .net ..can i show only percentage column which has less than 90%
in red color and more than 90% in green color in gried. or i have tables for day data and i wanna show all data in a gried with date specified in header of colimns..

rinkySingh
Go to Top of Page
   

- Advertisement -