如何在sql server 2008中进行查询以从多个表中获取数据并使用自定义分页绑定gridview [英] How to make query in sql server 2008 to fetch data from multiple table and bind gridview with custom paging

查看:79
本文介绍了如何在sql server 2008中进行查询以从多个表中获取数据并使用自定义分页绑定gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个表,我需要从中获取数据并在gridview中绑定自定义我的表模式,如tblStudent(id identity(1,1)pk,name nvachar(100)mobileNo char(10))second is tblMessage (id identity(1,1)pk,message nvarchar(1000)),third tblMsgHistory(id identity(1,1)pk,stuId int引用tblStudent(id),msgId int引用tblMessage(id),msgdate smalldatetime,deleverysatatus bool )



i想要使用@pageindex和@pagesize条件加入这三个表来获取数据



请告诉我如何实现我的程序



i使用sqlserver 2008和asp.net 4.0使用c#

解决方案

要进行查询以从多个表中获取数据,您必须使用像内部联接一样的加入。



创建联接的步骤 -



右键单击数据库,然后单击查询。

您的数据库将在弹出窗口中显示所有表格。

选择要获取数据的表格。并且

拖放所有表主键和检查字段名称你想要的。

自动连接将创建以下并执行比...并使用它。

一切顺利..


请参考以下链接:



加入三张或更多桌子



SQL Server 2008 - 如何加入3个表


带有3个表的SQL内连接

I have three table from which i need to fetch data and bind in gridview with custom pagging my table schema like tblStudent (id identity(1,1) pk,name nvachar(100) mobileNo char(10)) second is tblMessage (id identity(1,1) pk, message nvarchar(1000)), third tblMsgHistory (id identity(1,1) pk, stuId int references tblStudent(id),msgId int references tblMessage (id), msgdate smalldatetime, deleverysatatus bool)

i want to fetch data these three table using join with my @pageindex and @pagesize condition

please tell me how i can implement my procedure

i am using sqlserver 2008 and asp.net 4.0 with c#

解决方案

To make query to fetch data from Multiple table you have to use Join like Inner Join.

Steps for Create Joins-

Right Click on your database and click on Query .
Your database all tables will show on pop-up.
Select your Table which you want to fetch data. and
Drag and Drop All Tables Primary Keys and Check Fields name which your want.
Automatic Joins will Create the below and execute than..and use it.
All the best..


Refer to links below:

Joining Three or More Tables

SQL Server 2008 - How to Join 3 tables

SQL Inner-join with 3 tables


这篇关于如何在sql server 2008中进行查询以从多个表中获取数据并使用自定义分页绑定gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆