现在我有两张表,内容如下:表A (正文)
ID Contents
1 aabbcc
2 abc
3 acd
4 abb表B (关键字表)
ID Keyword
1 ab
2 ac
3 aa
4 ko现在需要把正文表中含有表B关键字的记录去除,请问在Mysql中通过SQL、存储过程或者函数可以实现吗(比如有没有delete from A where Contents in (select Keyword from B) 这样的语句)?请解答的详细点,谢谢!
ID Contents
1 aabbcc
2 abc
3 acd
4 abb表B (关键字表)
ID Keyword
1 ab
2 ac
3 aa
4 ko现在需要把正文表中含有表B关键字的记录去除,请问在Mysql中通过SQL、存储过程或者函数可以实现吗(比如有没有delete from A where Contents in (select Keyword from B) 这样的语句)?请解答的详细点,谢谢!
解决方案 »
- 有没有命令修改MySQL的日期的格式的?
- 关于sql优化 之 order by
- select id from book MINUS select id from new;
- 急急急急急!关于JAVA和MYSQL数据库的问题
- 微软群集环境中安装mysql只能通过命令mount mysql
- 如何编译MySQL ODBC源码生成ODBC安装程序?
- 一條 select 語句,為什麼出錯呢?
- mysql下,怎么执行一个外部sql文件,对空数据库建表,建数据
- 解? 当当前所有的表均被锁定时,UNLOCK TABLES可以提交事务
- Mysql5.6.10插入中文乱码??号
- 求mysql查询语句
- 关于正则表达式匹配的问题,求教高手
要求结果出来看看
因为
1 aabbcc
2 abc
3 acd
4 abb 都满足被过滤的要求。谢谢
select * from ba inner join bb on instr(ba.Contents,bb.Keyword)>0
where bb.id is null
select *
from a
where not exists (select * from b where a.Contents like concat('%',Keyword,'%'));
from a left join b on INSTR(a.Contents,b.Keyword)>0
where b.id is null