Im working on a page within a site where users need to be able to search for combinations of a 3 digit number that are stored in an access 2000 database.
So if John Doe wants to know what combinations of the sequence 1 - 2 - 3 exist in the database the following types of data would be returned:
3 - 1 - 2
2 - 3 - 1
1 - 2 - 3
Im using a form that posts the results to itself and heres my sql statement... (below) ... the problem is that it retrieves instances where even ONE digit matches as opposed to returning ONLY the records where the 3 numbers are represented... what am I doing wrong - still somewhat a newbie with ASP - but I know that this is possible ... it has to be.
' Build our query based on the input.
strSQL = "SELECT id, drawmonth, drawday, drawyear, digit1, digit2, digit3 " _
& "FROM pick3 " _
& "WHERE digit1 LIKE '%" & strSearch1 & "%' OR digit1 LIKE '%" & strSearch2 & "%' OR digit1 LIKE '%" & strSearch3 & "%'" _
& "And digit2 LIKE '%" & strSearch2 & "%' OR digit2 LIKE '%" & strSearch1 & "%' OR digit2 LIKE '%" & strSearch3 & "%'" _
& "And digit3 LIKE '%" & strSearch3 & "%' OR digit3 LIKE '%" & strSearch1 & "%' OR digit3 LIKE '%" & strSearch2 & "%'" _
& "ORDER BY id;"
So if John Doe wants to know what combinations of the sequence 1 - 2 - 3 exist in the database the following types of data would be returned:
3 - 1 - 2
2 - 3 - 1
1 - 2 - 3
Im using a form that posts the results to itself and heres my sql statement... (below) ... the problem is that it retrieves instances where even ONE digit matches as opposed to returning ONLY the records where the 3 numbers are represented... what am I doing wrong - still somewhat a newbie with ASP - but I know that this is possible ... it has to be.
' Build our query based on the input.
strSQL = "SELECT id, drawmonth, drawday, drawyear, digit1, digit2, digit3 " _
& "FROM pick3 " _
& "WHERE digit1 LIKE '%" & strSearch1 & "%' OR digit1 LIKE '%" & strSearch2 & "%' OR digit1 LIKE '%" & strSearch3 & "%'" _
& "And digit2 LIKE '%" & strSearch2 & "%' OR digit2 LIKE '%" & strSearch1 & "%' OR digit2 LIKE '%" & strSearch3 & "%'" _
& "And digit3 LIKE '%" & strSearch3 & "%' OR digit3 LIKE '%" & strSearch1 & "%' OR digit3 LIKE '%" & strSearch2 & "%'" _
& "ORDER BY id;"