开发者

Convert an SQL expression if it has a LENGTH function with SUBSELECT query to SQLite

开发者 https://www.devze.com 2023-04-06 22:56 出处:网络
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:

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 Dig开发者_开发技巧erBilg  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?


You will want to restructure your statement to be more similar to the following.

select length(name) from (select name from tblnames where name=1);

You can manage this a bit more easily by aliasing the subselects if you like.

select length(t.name) from (select name from tblnames where name=1) as t;
0

精彩评论

暂无评论...
验证码 换一张
取 消