常用sql语句
Posted Tomatoes
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了常用sql语句相关的知识,希望对你有一定的参考价值。
1.模糊匹配,b表记录不在a表中的
select b.name,a.zymc from a left join b on instr(b.name,a.zymc) >0 where b.name is null;
2.根据主副id拼出目录
select c.id_directory_parent, -- c表副id c.id_directory, -- c表主id b.id_directory, -- b表主id a.id_directory, -- a表主id case when b.id_directory_parent is null then ‘/‘ || a.directory_name when c.id_directory_parent is null then ‘/‘ || b.directory_name || ‘/‘ ||a.directory_name else ‘/‘ || c.directory_name || ‘/‘ || b.directory_name || ‘/‘ || a.directory_name end as ml from r_directory a left join r_directory b on a.id_directory_parent = b.id_directory left join r_directory c on b.id_directory_parent = c.id_directory
以上是关于常用sql语句的主要内容,如果未能解决你的问题,请参考以下文章