【发布时间】:2014-10-29 18:59:17
【问题描述】:
我有以下 SQL 查询:
SELECT
[content_id] AS [LinkID]
, dbo.usp_ClearHTMLTags(CONVERT(nvarchar(600), CAST([content_html] AS XML).query('root/Physicians/name'))) AS [Physician Name]
, [content_status] AS [Status]
, CAST ([content_html] AS XML).value('(root/Physicians/picture/img/@src)[1]','varchar(255)') AS [Image]
, dbo.usp_ClearHTMLTags(CONVERT(nvarchar(600), CAST([content_html] AS XML).query('root/Physicians/gender'))) AS [Gender]
, CAST ([content_html] AS XML).query('/root/Physicians/OfficeLocations/office1/a') AS [Office1]
, dbo.usp_ClearHTMLTags(CONVERT(nvarchar(600), CAST ([content_html] as XML).query('/root/Physicians/langF3'))) AS [Lang3]
, dbo.usp_ClearHTMLTags(CONVERT(nvarchar(600), CAST ([content_html] as XML).query('/root/Physicians/langF4'))) AS [Lang4]
, dbo.usp_ClearHTMLTags(CONVERT(nvarchar(600), CAST ([content_html] as XML).query('/root/Physicians/langF5'))) AS [Lang5]
FROM
[mydb].[dbo].[content]
WHERE
(content_html LIKE '%'+@strInsurance+'%')
strInsurance 是用户正在搜索的 DropDownList 值。在当前状态下,查询会搜索任何出现的事件并将其显示在结果中。
我已经设置了一个表格,其中有两个选项,要么勾选All Insurances,要么输入医生不接受的保险。
表格截图:
来自content_html 列的示例 XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Physicians>
<name>Z H MD</name>
<picture />
<gender>M</gender>
<langAccept />
<insAll>false</insAll>
<notIns1>
<a href="/default.aspx?id=2871" title="Great West Healthcare">Great West Healthcare</a>
</notIns1>
<notIns2>
<a href="/default.aspx?id=2862" title="Archcare Advantage SNP">Archcare Advantage SNP</a>
</notIns2>
<notIns3>
<a href="/default.aspx?id=2877" title="Magnacare">Magnacare</a>
</notIns3>
<notIns4 />
<notIns5 />
<notIns6 />
<notIns7 />
<notIns8 />
<notIns9 />
<notIns10 />
<specialty />
<specialty2 />
<specialty3 />
</Physicians>
</root>
所以,上述医生将接受除上述三种以外的所有保险。
我想要实现的目标:如果用户选择Great West Healthcare {从下拉列表},上面的医生不会出现,但如果用户选择“蓝十字蓝盾”{从下拉列表},上面的医生会出现的。
如何修改 SQL 查询以实现该目的或使用后面的代码。
我目前有一个只显示每一列的中继器。
【问题讨论】:
标签: c# asp.net sql-server xml