34,837
社区成员




//判断的条件,也可以在程序里写好,比如
string sql = "select * from TableName where 1=1 ";
if (title != '')
{
sql += " and title = '" + title + "'";
}
//...
//最后,执行sql就可以了.如果都为空,就返回全部记录.
//判断的条件,也可以在程序里写好,比如
string sql = "select * from TableName where 1=1 ";
if (title <> '')
{
sql += " and title = '" + title + "'";
}
//...
//最后,执行sql就可以了.如果都为空,就返回全部记录.
SELECT * FROM TB WHERE
classid1=ISNULL(@classid1,classid1) AND
classid2=ISNULL(@classid2,classid2) AND
classid3=ISNULL(@classid3,classid3)
???????select * from TableName where (classid1=@classid1 or @classid1 is null)
And (classid2=@classid2 or @classid2 is null)
And (title =@title or @title is null)