本文介绍了根据sql server中的多个条件过滤表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有6个列表框和三个日期文本框,我用它来对数据库表应用条件过滤。我需要的是,如果我只选择一个文本框或列表框值,或多个列表框值和多个日期值,我应该能够根据前端选择的过滤条件检索数据。我应该跳过我没有选择的日期或列表框值。 我有以下查询但它不起作用。我该如何编写查询?I have 6 listboxes and three date textboxes which I'm using to apply conditional filtering on a database table. What I need is if I select only a single textbox or a listbox value, or multiple listbox values and multiple date values I should be able to retrieve data based on only selected filter conditions from front end. The date or listbox values that I don't select should be skipped.I have the following query but its not working.How should i write the query?SELECT (MPMST.partyname + '' + ',' + '' + MPMST.contactperson) AS NAME ,(MPMST.email + '' + ',' + '' + MPMST.phone) AS ContactDetail ,MPMST.address ,(MPMST.city + '' + ',' + '' + MPMST.area) AS city_area ,MPMST.Already_Computer ,MPMST.software ,visit_time ,visit_purpose ,interactionFROM MPMSTINNERJOIN MCall ON MPMST.Partycode = MCall.PartycodeWHERE MCall.calltype IN ('SUP001')AND MPMST.area IN ('pavai')AND MPMST.city IN ('mumbai')AND MCall.Date >= CONVERT(DATETIME ,'01/01/2014' ,103)AND MCall.Date <= CONVERT(DATETIME ,'31/01/2014' ,103) MCall.status = ''AND MPMST.software = ''AND MPMST.Software <> ''AND MPMST.City IS NOT NULLAND MPMST.Area IS NOT NULL 我以前的查询就好像my previous query was likeWHERE MCall.calltype IN ('SUP001') OR MPMST.area IN ('pavai') OR MPMST.city IN ('mumbai') AND OR MCall.status = '' OR MPMST.software = '' AND MPMST.Software <> '' AND MPMST.City IS NOT NULL AND MPMST.Area IS NOT NULL ..这个查询只给了我满足第一个条件的记录ie.Sup001'..this query gave me only the records satisfying the first condition i.e..'Sup001'推荐答案 这篇关于根据sql server中的多个条件过滤表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-11 16:01