如果 SQL 表达式具有带有 SUBSELECT 查询的 LENGTH 函数,则将其转换为 SQLite
我知道在 SQLite 中,我们使用 LENGTH
函数而不是 len
。但是,当我想将 LENGTH
函数与子查询一起使用时,如下所示:
select length(select name from tblNames where name=1)
我收到错误。这是表达式的 Microsoft SQL 版本:
iif(len((select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)))>0,( select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)),Cstr(Dr.Fr)) as Fr,
我将上面的表达式转换为 SQLite,如下所示:
(case length((select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=CAST(Dr.Fr as TEXT))>0 ( select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)) else CAST(Dr.Fr as TEXT) end) as Fr,
我做错了什么?我不能仅将 SUBSELECT
查询与 LRNGTH
函数一起使用吗?关于如何解决这个问题有什么建议吗?
I know that in SQLite, we use the LENGTH
function instead of len
. But when I want to use the LENGTH
function with a subquery like so:
select length(select name from tblNames where name=1)
I receive an error. Here is the Microsoft SQL version of the expression:
iif(len((select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)))>0,( select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)),Cstr(Dr.Fr)) as Fr,
I converted the above expression into SQLite as so:
(case length((select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=CAST(Dr.Fr as TEXT))>0 ( select BilgiAcik from DigerBilg where BilgTip=12 and BilgDgr=Cstr(Dr.Fr)) else CAST(Dr.Fr as TEXT) end) as Fr,
What I'm I doing wrong about? Can't I just use the SUBSELECT
query with the LRNGTH
function? Any suggestions on how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要重组您的声明,使其更类似于以下内容。
如果您愿意,您可以通过为子选择添加别名来更轻松地管理它。
You will want to restructure your statement to be more similar to the following.
You can manage this a bit more easily by aliasing the subselects if you like.