gpt4 book ai didi

sql - Select using Like 上的 ActionScript 和 SQLite 参数

转载 作者:行者123 更新时间:2023-12-03 17:50:35 26 4
gpt4 key购买 nike

我试着在谷歌上找,但没有运气......

我有一个 SELECT SQLStatement我想使用 LIKE运算符,但参数不起作用,查询给我一个错误

    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' parameter name(s) found in parameters property but not in the SQL specified.

最佳答案

我解决了放置通配符 %在参数而不是语句中...

        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 中)被视为文本而不是参数本身......

关于sql - Select using Like 上的 ActionScript 和 SQLite 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8384464/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com