表TABLE中有两个字段:A、B,要找出字段A是字段B的一个子字符串的纪录,例如A是'abc',B是'abcde',但是like和IN好像都不好用,
select * from table where b like '%'||a||'%';
select * from table where a in b
都报错.
...全文
18110打赏收藏
求解一个SQL语句
表TABLE中有两个字段:A、B,要找出字段A是字段B的一个子字符串的纪录,例如A是'abc',B是'abcde',但是like和IN好像都不好用, select * from table where b like '%'||a||'%'; select * from table where a in b 都报错.
insert into table(A,B) VALUES('ab','abbs');
insert into table(A,B) VALUES('abbs','abss');
insert into table(A,B) VALUES('abb','ab');
select * from table where Locate(a,b)>0;这条语句的执行结果是只查询A='ab',B='abbs'这一条值.
select * from table where a in(select b from table)这条语句的执行结果是A='ab',B='abbs'和A='abbs',B='abss'这两条值.