<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 25, 2012, at 9:32 PM, George Parkinson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: 'lucida console', sans-serif; font-size: 10pt; position: static; z-index: auto; "><div><div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">hello all,</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">i'm not sure what to make of this...</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;"><br></font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">"SELECT * FROM t WHERE t.AgencyID in (996,998,1195)"</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">returns all records where AgencyID one of 996, 998, or 1195...no problem here.</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;"><br></font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">now, let's say i have an array-> SqlBind(1) =
"996,998,1195"</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">and i use this format -> <span class="Apple-tab-span" style="white-space:pre"> </span> "SELECT * FROM t WHERE t.agencyid IN (:1)"</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;"><br></font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">when i run:</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">db.SqlSelect(SQLQuery, kClientSide, kNoLocks, kForwardOnly, SQLBind)</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">only records where t.AgencyID = 996 are returned.</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;"><br></font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">is this normal?</font></div><div><font size="2" style="font-family:
arial, helvetica, sans-serif;">can't binding be used with "IN"?</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;"><br></font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">thanks,</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;">george</font></div><div><font size="2" style="font-family: arial, helvetica, sans-serif;"><br></font></div><div><br></div></div></div></div></div></blockquote></div><div><br></div>Yes, it is correct.<div>Binding is not a simple substitution like a wildcards.</div><div>And you can not pass a list of values as a single value.</div><div><br></div><div>There are few options:</div><div><br></div><div>1. Concat. the query in your app - something like this one:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>String query = "select....IN(" + valueList + ");"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>db.SqlSelect( query);</div><div><br></div><div>2. Binding - "IN (:1, :2, :3 )" in case you know how many items in the list.</div><div><br></div><div>3. In case you get the list from the database in some way you should combine both queries in a single statement:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>"select * from t1 where f1 IN (select id from t2 where....)</div><div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>-- <br>Best regards,<br>Ivan Smahin<br>Senior Software Engineer<br>Paradigma Software, Inc<br>Valentina - The Ultra-Fast Database<br><a href="http://www.valentina-db.com/">http://www.valentina-db.com</a></div></span>
</div>
<br></div></body></html>