• <tfoot id='9Z1j2'></tfoot>

  • <i id='9Z1j2'><tr id='9Z1j2'><dt id='9Z1j2'><q id='9Z1j2'><span id='9Z1j2'><b id='9Z1j2'><form id='9Z1j2'><ins id='9Z1j2'></ins><ul id='9Z1j2'></ul><sub id='9Z1j2'></sub></form><legend id='9Z1j2'></legend><bdo id='9Z1j2'><pre id='9Z1j2'><center id='9Z1j2'></center></pre></bdo></b><th id='9Z1j2'></th></span></q></dt></tr></i><div id='9Z1j2'><tfoot id='9Z1j2'></tfoot><dl id='9Z1j2'><fieldset id='9Z1j2'></fieldset></dl></div>

    1. <legend id='9Z1j2'><style id='9Z1j2'><dir id='9Z1j2'><q id='9Z1j2'></q></dir></style></legend>

        <small id='9Z1j2'></small><noframes id='9Z1j2'>

        • <bdo id='9Z1j2'></bdo><ul id='9Z1j2'></ul>

        SQLite:将值列表绑定到“WHERE col IN (:PRM)";

        时间:2023-10-26

          <bdo id='uDEW7'></bdo><ul id='uDEW7'></ul>

            <tbody id='uDEW7'></tbody>

              <small id='uDEW7'></small><noframes id='uDEW7'>

              <legend id='uDEW7'><style id='uDEW7'><dir id='uDEW7'><q id='uDEW7'></q></dir></style></legend>
              <i id='uDEW7'><tr id='uDEW7'><dt id='uDEW7'><q id='uDEW7'><span id='uDEW7'><b id='uDEW7'><form id='uDEW7'><ins id='uDEW7'></ins><ul id='uDEW7'></ul><sub id='uDEW7'></sub></form><legend id='uDEW7'></legend><bdo id='uDEW7'><pre id='uDEW7'><center id='uDEW7'></center></pre></bdo></b><th id='uDEW7'></th></span></q></dt></tr></i><div id='uDEW7'><tfoot id='uDEW7'></tfoot><dl id='uDEW7'><fieldset id='uDEW7'></fieldset></dl></div>

                1. <tfoot id='uDEW7'></tfoot>
                  本文介绍了SQLite:将值列表绑定到“WHERE col IN (:PRM)";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想做的就是发送一个类似的查询

                  all I want to do is send a query like

                  SELECT * FROM table WHERE col IN (110, 130, 90);
                  

                  所以我准备了以下声明

                  SELECT * FROM table WHERE col IN (:LST);
                  

                  然后我用

                  sqlite_bind_text(stmt, 1, "110, 130, 90", -1, SQLITE_STATIC);
                  

                  不幸的是,这变成了

                  SELECT * FROM table WHERE col IN ('110, 130, 90');
                  

                  and 没用(注意两个额外的单引号).我已经尝试在字符串中添加额外的 ' 但它们被转义了.我没有找到关闭转义或防止文本被单引号括起来的选项.我能想到的最后一件事是不使用准备好的语句,但我只将其作为最后的选择.您有什么想法或建议吗?

                  and is useless (note the two additional single quotes). I already tried putting extra ' in the string but they get escaped. I didn't find an option to turn off the escaping or prevent the text from being enclosed by single quotes. The last thing I can think of is not using a prepared statement, but I'd only take it as last option. Do you have any ideas or suggestions?

                  谢谢

                  参数的数量是动态的,所以它可能是三个数字,如上例所示,一个或十二个.

                  The number of parameters is dynamic, so it might be three numbers, as in the example above, one or twelve.

                  推荐答案

                  可以动态构建表单的参数化 SQL 语句

                  You can dynamically build a parameterized SQL statement of the form

                   SELECT * FROM TABLE WHERE col IN (?, ?, ?)
                  

                  然后为每个?"调用 sqlite_bind_int 一次您添加到语句中.

                  and then call sqlite_bind_int once for each "?" you added to the statement.

                  无法将一个文本参数直接绑定到多个整数(或者,就此而言,多个文本)参数.

                  There is no way to directly bind a text parameter to multiple integer (or, for that matter, multiple text) parameters.

                  这是我想到的伪代码:

                  -- Args is an array of parameter values
                  for i = Lo(Args) to Hi(Args)
                     paramlist = paramlist + ', ?'
                  
                  sql = 'SELECT * FROM TABLE WHERE col IN (' + Right(paramlist, 3)  + ')'
                  
                  for i = Lo(Args) to Hi(Args)
                    sql_bind_int(sql, i, Args[i]
                  
                  -- execute query here.
                  

                  这篇关于SQLite:将值列表绑定到“WHERE col IN (:PRM)";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将两行合并为一行,同时替换空值 下一篇:Microsoft SQL Server 从选择查询插入

                  相关文章

                      <bdo id='RgwHZ'></bdo><ul id='RgwHZ'></ul>
                      <i id='RgwHZ'><tr id='RgwHZ'><dt id='RgwHZ'><q id='RgwHZ'><span id='RgwHZ'><b id='RgwHZ'><form id='RgwHZ'><ins id='RgwHZ'></ins><ul id='RgwHZ'></ul><sub id='RgwHZ'></sub></form><legend id='RgwHZ'></legend><bdo id='RgwHZ'><pre id='RgwHZ'><center id='RgwHZ'></center></pre></bdo></b><th id='RgwHZ'></th></span></q></dt></tr></i><div id='RgwHZ'><tfoot id='RgwHZ'></tfoot><dl id='RgwHZ'><fieldset id='RgwHZ'></fieldset></dl></div>
                      <tfoot id='RgwHZ'></tfoot>

                    1. <small id='RgwHZ'></small><noframes id='RgwHZ'>

                    2. <legend id='RgwHZ'><style id='RgwHZ'><dir id='RgwHZ'><q id='RgwHZ'></q></dir></style></legend>