我已经尝试过了:
select p.name as publisher, b.title, b.name as name_
from book b, publisher p
where b.title like '%c%'
and (b.title not like 'c%' or b.title not like '%c')
and b.idpublisher = p.idpublisher;
但它仍然打印出首先包含'c'的标题 as you can see on this image
我做错了什么? PS:我正在使用SQLdeveloper
答案 0 :(得分:2)
仅使用like
的一种方法是:
where title like '%c%' and
title not like 'c%' and
title not like '%c';
另一种方法是使用正则表达式:
where regexp_like(title, '^[^c].*[c].*[^c]$')