Py学习  »  DATABASE

mysql-在%x中选择标题所属的位置-在

Krystian Walicki • 5 年前 • 1151 次点击  

我有带标题的表格(标题栏)

以及带有删节词的表(名称列)。

示例标题可以是: Ever Sex Mount!

另一张桌子上的一个删节词是 sex

出现在标题中 永远的性爱山!

因此,应该从结果集中排除此记录。

所以…

我如何从一个表中选择所有记录,其中它们的标题不使用任何来自另一个表的禁止字,该表使用 name

是关于子串的。通常是这样做的… WHERE title NOT LIKE "%sex%" 我想

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40581
 
1151 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Gordon Linoff
Reply   •   1 楼
Gordon Linoff    6 年前

你似乎想要:

select t.*
from titles t
where not exists (select 1
                  from bannedwords bw
                  where t.title not like '%' + bw.name + '%'
                 );

当然,这个逻辑也会排除任何带有“essex”或“sussex”或“middlesex”或“sextuplet”等的标题。