SQLite 变量
问候!
我正在使用 SQLite。我想声明变量,但它给了我一个语法错误。请帮助我找到解决方案:
Select * from t2 where value= ?
这是我的查询。现在如何将值传递给 ?
?
预先感谢,珍妮
Greetings!
I am using SQLite. I want to declare variable, but it gives me a syntax error. Please help me to find a solution:
Select * from t2 where value= ?
This is my query. Now how can I pass values to ?
?
Thanks in advance, Jennie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知 SQLite 不支持类似的东西。
对于实现绑定参数(以及使用它们的准备好的语句)的库来说,语法是标准的,但您需要使用查询数据库的编程语言而不是数据库本身来执行此操作。
当然,具体细节取决于编程语言和库。
例如,在 Perl 中,您可以:
Bobby Tables 有多种语言的一些更多示例。
As far as I know SQLite doesn't support anything like that.
The syntax is standard for libraries that implement bound parameters (and prepared statements that use them), but you would need to do that in a programming language that queries the database, and not in the database itself.
The specifics, of course, depend on the programming language and the library.
In Perl, for example you could:
Bobby Tables has some more examples in a variety of languages.
您可以使用内存临时表支持 sqlite 中的变量。请参阅我的答案 https://stackoverflow.com/a/14574227/1435110
You can support variables in sqlite using an in-memory temp table. See my answer at https://stackoverflow.com/a/14574227/1435110
使用此类变量的唯一方法是使用绑定函数。在许多情况下,用您所使用的语言构建查询字符串会更容易。
The only way to use variables like that is by using the binding functions. In many cases, constructing a query string in the language you are using is easier.