如何使用SQL Server 2008从C#中的多个表中选择计数 [英] how to select counts from multiple tables in C# with SQL server 2008

查看:101
本文介绍了如何使用SQL Server 2008从C#中的多个表中选择计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像
这样的表

i have a table like

bookid------book code -------book title-------ISBN-------AUTHOR
21-------zzzzzzzz-0001-------das--------------222--------das
22-------zzzzzzzz-0002-------das--------------222--------das
23-------java,api-0003-------Learn Java	------231--------Dietel
24-------java,api-0004-------Learn Java	------231--------Dietel
25-------java,api-0005-------Learn Java	------231--------Dietel
26-------corejava-0006-----Core Java Volume---222--------Ram 



该表中还有其他几个字段.
现在我想在网格中显示数据,如下所示



there are several other fields too in this tables.
now i want to display data in a grid as folllows

Title.................Book Code........................ISBN....... Author...... Stock nos.
Learn Java..... java,api-0003,0004,0005.....................231.........Dietel..........3
das..................zzzzzzzz-0001,0002.....................222.........Ram.............2


任何帮助或提示将不胜感激....

[edit]添加了代码块,整理后的格式-OriginalGriff [/edit]


any help or hint will be appreciated....

[edit]Code Blocks added, formatting tidied - OriginalGriff[/edit]

推荐答案

假定您对此进行数据绑定,则将按引用它们的顺序显示列SELECT语句,您可以提供比表中包含的更好,更人性化的名称:
Assuming you are databinding this, the columns will be displayed in the order you reference them in the SELECT statement, and you can provide better, more human friendly names than your table contains:
SELECT [book title] AS Title, [book code] AS [Book Code], ISBN, Author, StockLevel AS [Stock nos.] FROM myTable

可能会为您提供所需的数据.

Would probably give you the data you require.


这篇关于如何使用SQL Server 2008从C#中的多个表中选择计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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