|
| |
|
|
washurjosh
Posts: 66 Joined: 1/18/2006 Status: offline
|
query with checkbox values - 5/1/2006 18:29:21
Perhaps this has already been covered, but i didnt find specific enough information about my issue. what is going on is that i have one page that has a form with some check boxes with different values that i want to query my database to see if my field "age" contains one of those value of the check box that was checked (also allow mulitple checked boxes) a normal record's field "age" would look something like this 20s, 30s, 40s, my check box values are: teens 20s 30s 40s 50s 60s so how do i query the comma diliminated field to see if it has any of those individual values. I got it to work if you just check one box or if the record includes all of the values of the boxes you checked. can anyone offer specific info on how i would structure my sql to do this. THANKs
|
|
|
|
BeTheBall
Posts: 6385 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: query with checkbox values - 5/1/2006 18:43:44
Assuming you have named each checkbox the same. SELECT * FROM tblName WHERE Instr('"&Request.Form("checkboxName")&"',age)>0
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
washurjosh
Posts: 66 Joined: 1/18/2006 Status: offline
|
RE: query with checkbox values - 5/1/2006 18:51:47
currently what im using is this: SELECT * FROM Results WHERE (Sex LIKE '::Sex::%' AND age LIKE '%::age::%') ORDER BY last
|
|
|
|
washurjosh
Posts: 66 Joined: 1/18/2006 Status: offline
|
RE: query with checkbox values - 5/1/2006 19:57:51
I dont need the LIKE for the sex your right. I think it was left over from when i was doing something else with the page. however on to your sql you gave me. I am not sure what the last "age" is for. i mean i get the request.form one which would get the values from the form on the previous page. but should i write it like this????: SELECT * FROM Results WHERE (Sex = '::Sex::' AND Instr('"&Request.Form("age")&"','::age::')>0) ORDER BY last
|
|
|
|
washurjosh
Posts: 66 Joined: 1/18/2006 Status: offline
|
RE: query with checkbox values - 5/1/2006 20:17:32
Ok, so i figured a couple of things out and we have almost solved my issue. 1) the reason i used LIKE in the sex sql was because on my form i have three options; MALE, FEMALE, ALL and so my value for ALL=% 2) the second "age" i was talking about i found out why it is there, and thats because instr is a property you can use for sql and thats the structure. (this is where i solved the issue with the check boxes THANKS) 3) now that we are not using LIKE for the "age" field how do i make a checkbox that will display ALL results??
|
|
|
|
BeTheBall
Posts: 6385 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: query with checkbox values - 5/1/2006 20:31:00
Like this? <input type="checkbox" name="age" value="teens,20s,30s,40s,50s,60s">
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
washurjosh
Posts: 66 Joined: 1/18/2006 Status: offline
|
RE: query with checkbox values - 5/15/2006 3:27:02
see the problem i find with that is that it only gives me people that have all those types. But what i want is people that may have any combination of types or none at all. Does that make sense?
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|