ballerina.io类SQL语句
我目前正试图在ballerina.io中针对一个MariaDB执行以下SQL语句 计划SQL:ballerina.io类SQL语句,sql,mariadb,where-clause,sql-like,ballerina,Sql,Mariadb,Where Clause,Sql Like,Ballerina,我目前正试图在ballerina.io中针对一个MariaDB执行以下SQL语句 计划SQL: select * FROM testDB where test LIKE '%BA%'; 我得到一个包含所有数据的结果集 芭蕾舞演员: var selectRet = testDB->select("select * FROM testDB where test LIKE '%?%'", testREC, "BA"); 我得到一个空的结果集 版本: 芭
select * FROM testDB where test LIKE '%BA%';
我得到一个包含所有数据的结果集
芭蕾舞演员:
var selectRet = testDB->select("select * FROM testDB where test LIKE '%?%'", testREC, "BA");
我得到一个空的结果集
版本:
芭蕾舞演员——版本jBallerina 1.1.2 语言规范2019R3 芭蕾舞演员工具0.8.0 是否可以在ballerina.io中使用LIKE生成SQL语句 许多问候,
Martin参数作为单独的文本字符串传递给查询,而不是作为某种模板变量。要使用通配符将其包围,您需要在查询中使用
concat()
:
var selectRet = testDB->select(
"select * FROM testDB where test like concat('%', ?, '%')",
testREC,
"BA"
);
或者只是在代码中连接通配符(我觉得这看起来更简洁):
var selectRet = testDB->select(
"select * FROM testDB where test like ?",
testREC,
"%BA%"
);