SELECT count(*) as ReqNum ,svalue as Req
from tbuser
left join tbdic on dic = '"+DropDownList1.Items[this.DropDownList1.SelectedIndex].ToString()+"'
group by svalue
比如说CheckBox2被选中了
那么应该是这样:
string strSql="SELECT * FROM TableName WHERE 1=1 "
if (DropDownList1.SelectedIndex!=-1)
{
strSql=strSql + " AND 学位='"+DropDownList1.Items[this.DropDownList1.SelectedIndex].ToString()+"' "
}
if(CheckBox2.Checked==true)
{
strSql=strSql + " OR City ='"+CheckBox2.Text+"' "
}
...
"SELECT * FROM TableName WHERE 学位='"+DropDownList1.Items[this.DropDownList1.SelectedIndex].ToString()+"' AND City ='"+CheckBox1.Text+"' OR City ='"+CheckBox2.Text+"' OR City ='"+CheckBox3.Text+"'"