I have an app which allows the user to create their own search criteria (by selecting from any or all of 5 fields). The selections they can make come from values in combo boxes, so they can only search for data that pre-exists.
I have built an individual SELECT query for each searchable field. By testing to see if they have selected a value I build a UNION of these individual SELECT queries.
My problem is I only want records returned that match ALL the criteria. The way it works right now, it returns a record if it matches ANY single element of the criteria.
I am very inexperienced at building complex queries and this is the first time I have used a UNION. There's probably a better way to do this, but I am afraid I don't know what that would be.
Right now it is treating each element in the search criteria like an OR, whereas I need it to treat each element as an AND.
Can some one help???
TIA,
MDS
I have built an individual SELECT query for each searchable field. By testing to see if they have selected a value I build a UNION of these individual SELECT queries.
My problem is I only want records returned that match ALL the criteria. The way it works right now, it returns a record if it matches ANY single element of the criteria.
I am very inexperienced at building complex queries and this is the first time I have used a UNION. There's probably a better way to do this, but I am afraid I don't know what that would be.
Right now it is treating each element in the search criteria like an OR, whereas I need it to treat each element as an AND.
Can some one help???
TIA,
MDS