条件在SQL查询中的条款
发布时间:2020-12-12 08:44:42 所属栏目:MsSql教程 来源:网络整理
导读:我已经开发了用于生成报告的MVC应用程序.我提供了许多搜索选项,如下所示 Customer idCustomer nameCustomer E-mailStateCountry 用户1: 如果某些用户只能给出一些值的输入 Customer id = 1Customer name = A 默认情况下,其他参数将作为空值传递给存储过程. C
我已经开发了用于生成报告的MVC应用程序.我提供了许多搜索选项,如下所示
Customer id Customer name Customer E-mail State Country 用户1: 如果某些用户只能给出一些值的输入 Customer id = 1 Customer name = A 默认情况下,其他参数将作为空值传递给存储过程. Customer E-mail State Country 用户2: 如果某些用户只能输入一些值,例如 客户E-mail=xtz@gmail.com 默认情况下,其他参数将作为空值传递给存储过程. Customer id Customer name State Country 如何在存储过程中的SQL查询中使用where子句.我们可以像下面这样做吗 string qry = select * from table_name where status != d if (@customerID!=null) qry = qry + "and customer_id=@customerID" if (@customerName!=null) qry = qry + "and customer_name=@customerName" 请让我最好的方法. 谢谢, 解决方法你想知道的关于这个话题的一切,以及更多: Dynamic Search Conditions in T-SQL(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |