Hi there,
I have a record in my database which is comma delimeted, an example might be "orange, apple, pear" which is the result of a user selecting three items from a multi-select box or three checkboxes of the same name but with different values.
I have a form at the front-end containing a <select multiple> box containing a list of different fruits (as an example) which the User can select multiple items from to search. So when a user submits the form the Response.Form("fruit_type") value might be "orange, pear, strawberry, lemon" (if they picked 4 items from the select box list.
I'm trying to then construct a SQL SELECT statement to interogate my database which would have the following structure:
strSQL = "SELECT * FROM tblFruit WHERE fruit_type LIKE '%orange%' AND fruit_type LIKE '%pear%' AND fruit_type LIKE '%strawberry%' AND fruit_type LIKE '%lemon%' ORDER BY id"
The idea being that my record in the database which contains "orange, apple, pear" will be picked up because it contains one or more matching results.
Fundamentally my thought process would suggest I needed to put the form value "orange, pear, strawberry, lemon" into an array which is split at the comma (,) and then construct my SQL SELECT statement using a for...next loop.
I can't seem to figure out, however, how to actually code this up.
Can anyone help?