【
问题
描述】
执行命令
sdb "db.exec('select substr(pad,1,2) as sss,count(id) as count from sysbench_test.sbtest1 group by substr(pad,1,2)')"
时报错,报错信息如下:
(sdbbp):1 uncaught exception: -195
SQL syntax error
【解决方法】
目前内置
SQL
语法并不支持此类函数,仅支持聚集相关的函数。内置
SQL
功能不
够
全面,一般推荐用
SQL
引擎(
MySQL/PostgreSQL
),但是
标
准
SQL
语句中对
json
的操作的支持是比
较
弱。因此推荐直接用原生的
语
法去操作。具体参考更新符
$substr
:
http://doc.sequoiadb.com/cn/index-cat_id-1440656863-edition_id-302
【解决方法】
目前内置
SQL
语法仅支持
sum()
,
count()
,
avg()
,
max()
,
min()
,
first()
,
last()
,
push()
,
addtoset()
,
buildobj()
,
mergearrayset()
等函数,不支持
substr
函数。
由于内置
SQL
功能不
够
全面,一般推荐用
SQL
引擎(
MySQL/PostgreSQL
),但是
标
准
SQL
语句中对
json
的操作的支持是比
较
弱。因此推荐直接用原生的
语
法去操作,原生
语
法使用
$substr
命令:
db.cs.cl.find({}, {a:{$include:1, $substr:[1,2]}})
具体参考更新符
$substr
:
http://doc.sequoiadb.com/cn/index-cat_id-1440656863-edition_id-302
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69935160/viewspace-2649164/ ,如需转载,请注明出处,否则将追究法律责任。