cwilkey
06-20-2005, 07:40 AM
I have a search page that allows a user to enter search criteria such as a date range, author, etc. How can I setup multiple SQL statments based on the users input? For example, I may have 5 search fields and I want the query to be based on any of them being true, not just the first one. Here is what I've been trying and the query stops as soon as the first condition is true.
CODE:
"SELECT * FROM results WHERE ddate BETWEEN '" & startdate & "' AND '" & enddate & "'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND author = '" & author & "'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND news = 'Notified' OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND technical = 'Notified' OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND EAS = 'Notified' OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND Internet = 'Notified'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND MasterControl = 'Notified'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND Station = '" & station & "'OR station = '" & station & "'OR station = '" & station & "' AND author = '" & author & "'OR station = '" & station & "' AND mastercontrol = 'Notified'OR station = '" & station & "' AND technical = 'Notified'OR station = '" & station & "' AND news = 'Notified'OR station = '" & station & "' AND internet = 'Notified'OR station = '" & station & "' AND eas = 'Notified'OR mastercontrol = 'Notified' OR News = 'Notified' OR Technical = 'Notified' OR EAS = 'Notified'OR Internet = 'Notified'"
CODE:
"SELECT * FROM results WHERE ddate BETWEEN '" & startdate & "' AND '" & enddate & "'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND author = '" & author & "'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND news = 'Notified' OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND technical = 'Notified' OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND EAS = 'Notified' OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND Internet = 'Notified'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND MasterControl = 'Notified'OR ddate BETWEEN '" & startdate & "' AND '" & enddate & "' AND Station = '" & station & "'OR station = '" & station & "'OR station = '" & station & "' AND author = '" & author & "'OR station = '" & station & "' AND mastercontrol = 'Notified'OR station = '" & station & "' AND technical = 'Notified'OR station = '" & station & "' AND news = 'Notified'OR station = '" & station & "' AND internet = 'Notified'OR station = '" & station & "' AND eas = 'Notified'OR mastercontrol = 'Notified' OR News = 'Notified' OR Technical = 'Notified' OR EAS = 'Notified'OR Internet = 'Notified'"