如何通过查询复制列. [英] how copy acolumn by a query.
问题描述
在我的应用程序中
我使用查询,返回14行.
我需要为此结果添加一列(从另一个teble).
我通过使用内部联接而得到的,但它返回的行数超过14.
我只需要在14行中显示一个日期",14行的日期是相同的.
添加的tacble列包含一个参考字段.
查询如下
In my application
I used a query ,returns 14 rows.
I need to add a column to this result ( from a other teble).
I got by use of inner join but it returns more than 14 rows.
I just need to display a ''date '' in 14 rows ,the date is same for 14 rows.
The added column tacble containd a reference field.
query as below
SELECT distinct '99991', tbl_DisclosureTypeDetails.disclodetDisclosureId,isnull( tbl_Disclosures.Disclosures,'') AS Expr1
FROM tbl_DisclosureTypeDetails INNER JOIN
tbl_Disclosures ON tbl_DisclosureTypeDetails.disclodetDisclosureId = tbl_Disclosures.DiscId
WHERE (tbl_DisclosureTypeDetails.disclodetMasterId = (SELECT BMDisclosure
FROM tbl_BorrowersMaster
WHERE BMId = 223)) and tbl_DisclosureTypeDetails.disclodetDisclosureId NOT IN(SELECT BMCDisclosures
FROM tbl_BorrowersMasterChild
WHERE (BMCBorrowerID = 223))
推荐答案
您可以按照以下步骤进行操作.
You can do this as following.
SELECT distinct ''99991'', tbl_DisclosureTypeDetails.disclodetDisclosureId,isnull( tbl_Disclosures.Disclosures,'''') AS Expr1, (SELECT TOP 1 DATE_COLUMN FROM SOMEOTHERTABLE WHERE [CONDITION]) AS NEWCOLUMN
FROM .......
另一种方法是将列存储在临时表中,然后更新date列,最后从临时表返回结果.
The other way is to store the column in a temp table and update the date column afterwards and finally return the result form the temp table.
这篇关于如何通过查询复制列.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!