sqlite 变量 [英] sqlite variables
问题描述
您好!
我正在使用 SQLite.我想声明变量,但它给了我一个语法错误.请帮我找到解决方案:
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 ?
?
提前致谢,珍妮
推荐答案
据我所知,SQLite 不支持类似的东西.
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.
例如,在 Perl 中,您可以:
In Perl, for example you could:
my $sth = $dbh->prepare("Select * from t2 where value=?");
foreach my $value (@values) {
$sth->execute($value);
$row = $sth->fetchrow_hashref;
[...]
}
Bobby Tables 有多种语言的更多示例.
Bobby Tables has some more examples in a variety of languages.
这篇关于sqlite 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!