将两个表的值添加到新表aspnet C#webform中 [英] adding value of two table into new table aspnet C# webform
问题描述
0下来投票最爱
我有两张桌子如下。
1-桌子名称:Action01
ID Label01
1 Orange
2芒果
3柠檬
2-表名: - Action02
ID Label02
1 05数量
2 10数量
3 06数量
这些两个表获取服务器上输入数据的值
我想将值添加到新表名中:PurchaseList
3:表名:PurchaseList
ID购买
1橙色,05数量
2芒果,10个数量
3柠檬,06个数量
有谁能告诉我如何添加上面两个颜色(标签01和标签02)到新表coloumn(购买)。
目的是向首页的文本主体显示购买coloum值d然后它将在我的SQL报告中使用。
请参阅stackflow中其他评论的链接,但仍未解决!< br $> b $ b
http://stackoverflow.com/questions/24365627/adding-value-of-two-table-into-new-table-aspnet-c-sharp-webform / 24365707?noredirect = 1#comment37756364_24365707 [ ^ ]
关注Tahir
0 down vote favorite
I have two table are as follows.
1- Table name: Action01
ID Label01
1 Orange
2 Mango
3 Lemon
2- Table Name:- Action02
ID Label02
1 05 qty
2 10 Qty
3 06 Qty
These two table get the values on data entering on server
I want to add the values into new table name: PurchaseList
3: Tablename: PurchaseList
ID Purchasing
1 Orange, 05 qty
2 Mango, 10 qty
3 Lemon, 06 qty
Can anybody tell me how to add the above two coloumn(Label 01 and Label 02) into new table coloumn(purchasing) .
Purpose is to show purchasing coloum value into the textbody of front page and then later it will be use in my SQL reporting.
See links for other comments in stackflow which is still not solved!
http://stackoverflow.com/questions/24365627/adding-value-of-two-table-into-new-table-aspnet-c-sharp-webform/24365707?noredirect=1#comment37756364_24365707[^]
Regards Tahir
推荐答案
您可以通过简单的SQL查询来实现这一点,方法是将两个表连接到其ID并连接两个表列值
例如:
表1
------
ID ItemName
1芒果
2 Apple
3香蕉
表2
------
ID ItemValue
1 100
2 200
3 150
在Sql写作
You can do this by simple SQL Query by joining two tables by their Id and concatenating the two column values
For Example:
Table1
------
ID ItemName
1 Mango
2 Apple
3 Banana
Table2
------
ID ItemValue
1 100
2 200
3 150
In Sql write as
Select a.ID, a.ItemName+convert(b.ItemValue as varchar) as [ItemWithRate]
这篇关于将两个表的值添加到新表aspnet C#webform中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!