使用Like选择时的ActionScript和SQLite参数 [英] ActionScript and SQLite parameters on Select using Like
问题描述
我尝试在Google上搜索,但没有运气...
I tried looking on google but without luck...
我有一个SELECT SQLStatement
,我想使用LIKE
运算符,但参数将不起作用,查询会给我一个错误
I have a SELECT SQLStatement
and I want to use the LIKE
operator but the parameters won't work and the query give me an error
public function getUsersList(username:String):SQLStatement
{
selectRecord= new SQLStatement();
selectRecord.sqlConnection = connection;
selectRecord.text =
"SELECT id_user, username,password,profile,leg_cliente " +
"FROM userlist " +
"WHERE username like '%:username%'";
selectRecord.parameters[":username"] = username;
return selectRecord;
}
我得到的错误是
':username'参数名称在parameters属性中找到,但不在 指定的SQL.
':username' parameter name(s) found in parameters property but not in the SQL specified.
推荐答案
我解决了将通配符%
放入参数而不是语句中的问题...
I solved putting the wildcard %
in the parameters instead of the statement...
selectRecord.text =
"SELECT id_user, username,password,profile,leg_cliente " +
"FROM userlist " +
"WHERE username like :username";
selectRecord.parameters[":username"] = "%"+ username+"%";
由于查询类似
selectRecord.text =
"SELECT id_user, username,password,profile,leg_cliente " +
"FROM userlist " +
"WHERE username like '%:username%'";
我想这是因为参数键(在statement.text中)被视为文本而不是参数本身.
Putting the single quote in the statement won't let the statement to set the parameter, I suppose because the parameter key (in statement.text) is seen as a text and not a parameter itself...
这篇关于使用Like选择时的ActionScript和SQLite参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!