Replies Back to Article

Using the IN Operator to select multiple records

loop checkbox adds a nr
January 17, 2003 by Dennis van Galen

I tried this once, i could never get the insert loop to work, and neither did anyone here since i asked 4 times and spend many many hours on this, but i write to say that the loop adds nrs to the checkbox, if you have 100 cities and the first checkbox is called checkCity then the last in the array will be checkCity99.

I tried this just once in coldfusion and it just worked, cfquery insert into and voila it worked, crazy ! I wanted this for my knowledge base, select knowledge boxes to look for and in the admin section the same thing, only with insert. I guess when it's all on paper it will just be a matter of a few cfquery's and be done with it, glad i dumped asp. Wish i could dump the strict documenting and change requests and everything as well.

Dennis

RE: loop checkbox adds a nr
January 17, 2003 by Tjerk Heringa

Hi Dennis,

i'm a bit suprised that this part gave you trouble. In my case that was the easy part. But you might have mixes to things up, maybe. I am very sure that all checkboxes have the same name. And i am very sure that the info in the QS does too. But of course in a one dimensional array the values in the array get numbered.

But because you named the variable (the array) checkCity, this is still something you can use in a db-query.

Can this operator use Wildcart ?
February 11, 2003 by ran ran

The result of my form are like 45 or 46 or 47 and therecords in database are for example 46 or 46/1-2 or 46/3-4

In it possible to insert wildcart please ?

Is there some separate character tu use it ?

Thank you

RE: Can this operator use Wildcart ?
February 11, 2003 by Tjerk Heringa

Hi Ran,

I don't see why it shouldn't be possible.

Haven't tried it out, but something like this could work (in a quick and dirty way):

<%
QSCity = Request.Querystring("ReCity")
StrCities = Replace( QSCity, ", ", "'*,*'" )
%>

RE: RE: Can this operator use Wildcart ?
February 11, 2003 by ran ran

it don't work

and the version with OR don't work neither

it seem to be a bug from MS SQL

Ran

RE: Can this operator use Wildcart ?
March 11, 2003 by Rob Davis

In that case you'd need to store your data in a better format, or make sure that users cannot enter things like 45 1/2 using validation techniques, otherwise.

For instance if you used a float field, that would be 45.5 and then you could use BETWEEN in SQL.

works absolutey fine for DELETE as well
April 26, 2007 by K Makore
Hi, just to write many thanks for this tutorial, got everything working after 20 mins, i needed it mainly for deleting rather than selecting or updating, if you need to delete just changet he mysql statement to MySQL = "Delete City FROM tblCities WHERE ReCity IN ('" & StrCity & "')" and also just a heads up that at the top you refer to value StrCities and then later on refer to it as StrCity, suggest should be StrCity from the top (not StrCities) nice one. Kumbi