【问题描述】
执行命令 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的操作的支持是比较弱。因此推荐直接用原生的语法去操作。具体参考更新符
s
u
b
s
t
r
:
h
t
t
p
:
/
/
d
o
c
.
s
e
q
u
o
i
a
d
b
.
c
o
m
/
c
n
/
i
n
d
e
x
−
c
a
t
i
d
−
1440656863
−
e
d
i
t
i
o
n
i
d
−
302
【
解
决
方
法
】
目
前
内
置
S
Q
L
语
法
仅
支
持
s
u
m
(
)
,
c
o
u
n
t
(
)
,
a
v
g
(
)
,
m
a
x
(
)
,
m
i
n
(
)
,
f
i
r
s
t
(
)
,
l
a
s
t
(
)
,
p
u
s
h
(
)
,
a
d
d
t
o
s
e
t
(
)
,
b
u
i
l
d
o
b
j
(
)
,
m
e
r
g
e
a
r
r
a
y
s
e
t
(
)
等
函
数
,
不
支
持
s
u
b
s
t
r
函
数
。
由
于
内
置
S
Q
L
功
能
不
够
全
面
,
一
般
推
荐
用
S
Q
L
引
擎
(
M
y
S
Q
L
/
P
o
s
t
g
r
e
S
Q
L
)
,
但
是
标
准
S
Q
L
语
句
中
对
j
s
o
n
的
操
作
的
支
持
是
比
较
弱
。
因
此
推
荐
直
接
用
原
生
的
语
法
去
操
作
,
原
生
语
法
使
用
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:http://doc.sequoiadb.com/cn/index−catid−1440656863−editionid−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
【巨杉数据库Sequoiadb】【咨询】【内置SQL】执行exec命令查询substr函数时报错-195
最新推荐文章于 2021-05-02 13:28:28 发布