|
TexasWebDevelopers -> RE: IN - sql? (7/1/2009 10:28:26)
|
Is there an error message and if so what is it? How are you handling the comma spearators and the single quotes? This will work: WHERE CN_No IN ('123','124','125','126') but his, with the trailing comma after 126, will not: WHERE CN_No IN ('123','124','125','126',) and this will not: WHERE CN_No IN ('123,124,125,126') Note that all the variables have to have single quotes around them. You might want to response.write(your_sql) to see exactly what your sql statement looks like. We use a function to strip out the trailing comma after adding in the single quotes something like this: <script language='jscript' runat='server'> function commaKiller(x){ return x.replace(/,*$/,''); }; </script> <% str = str & "'" & Rs("CN_No") & "'," ' this bit adds single quotes and commas newCN_No=commaKiller(str) ' this function call strips out the last comma in the array %> sql = "SELECT * FROM [table-name] WHERE CN_No IN (" & newCN_No & ");"
|
|
|
|