作者:瀑布下的鱼 | 来源:互联网 | 2023-08-10 11:36
allIwanttodoissendaquerylike我想做的就是发送一个查询SELECT*FROMtableWHEREcolIN(110,130,90);
all I want to do is send a query like
我想做的就是发送一个查询
SELECT * FROM table WHERE col IN (110, 130, 90);
So I prepared the following statement
所以我准备了以下声明
SELECT * FROM table WHERE col IN (:LST);
Then I use
然后我用
sqlite_bind_text(stmt, 1, "110, 130, 90", -1, SQLITE_STATIC);
Unfortunately this becomes
不幸的是,这变成
SELECT * FROM table WHERE col IN ('110, 130, 90');
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?
并且没用(请注意另外两个单引号)。我已经尝试在字符串中添加额外的'但是它们会被转义。我没有找到关闭转义或防止文本被单引号括起来的选项。我能想到的最后一件事是没有使用准备好的声明,但我只把它作为最后一个选项。你有什么想法或建议吗?
Thanks
谢谢
Edit:
编辑:
The number of parameters is dynamic, so it might be three numbers, as in the example above, one or twelve.
参数的数量是动态的,因此它可能是三个数字,如上例所示,一个或十二个。
7 个解决方案