【发布时间】:2018-07-01 02:27:12
【问题描述】:
这是我的数据库表,我的下拉列表的 SqlDataSource SelectCommand 和我的下拉列表的文本和值字段属性。我希望我选择的国家/地区具有与之对应的所有 resultsId。我的意思是当我选择西班牙时,我希望 resultid 有 2 和 3。但问题是,在我的下拉列表中,我有重复的国家文本,我无法更改它。
country resultsId
spain 2
spain 3
china 2
china 4
canada 1
canada 4
england 1
england 3
usa 1
usa 2
SelectCommand="SELECT distinct countries, resultsid FROM countrytable"
DataTextField="country" DataValueField="resultsid"
我试过这个 SelectCommand:
SelectCommand="SELECT resultsId,(select country, count(*)
from countrytable group by country having count(*) >1) FROM countrytable
但是现在,我有这个错误:
Only one expression can be specified in the select list when the
subquery is not introduced with EXISTS
我正在使用 sql server 和 asp.net c#
【问题讨论】:
标签: c# asp.net sql-server