display the four table value in grid view

Posted by Sekar.C under Sql Server on 3/19/2012 | Points: 10 | Views : 1190 | Status : [Member] | Replies : 4
hi,
I use four tables (Hospital, Market, Restaurant, and Transport) in same fields like name, distance, Location ,quality and FlatID .I want display the four table value based on flatID in single query using sql server 2005
Regards
sekar.c

Regards
Sekar.c



Responses

Posted by: Sksamantaray on: 3/20/2012 [Member] Silver | Points: 25

Up
0
Down

create a stored procedure with flatid as parameter

create procedure spViewData

@FlatID int
as
Begin
select col1,col2,col3... from table1 where flatid=@FlatID
union
select col1,col2,col3... from table2 where flatid=@FlatID
union
select col1,col2,col3... from table3 where flatid=@FlatID
union
select col1,col2,col3... from table4 where flatid=@FlatID

End


Then bind the result in gridview.
Mark as Answer if it works else let me know the problem

Thanks,
Sanjay

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/19/2012 [Member] Starter | Points: 25

Up
0
Down
SELECT name, distance, Location ,quality , FlatID
FROM
Hospital, Market, Restaurant, Transport WHERE FLATID=12

REGARDS
SRIRAM.R

sriram

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 5/21/2012 [Member] Starter | Points: 25

Up
0
Down
Go to View tutorial....then create View (view is a virtual table which is a collection of more then one table...)

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kavi.Sirius on: 5/30/2012 [Member] Starter | Points: 25

Up
0
Down
hi

use join to write the query



Regards
Kavi.n

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response