+ -
当前位置:首页 → 问答吧 → mysql 查询问题

mysql 查询问题

时间:2011-11-14

来源:互联网

有表id_cotent

id content
1 <Font Face='宋体' Color='-16777216' Size='10'>你好 </Font>
2 宋代是人
3 宋朝灾星
4 woesldfjs
5 我地个身

sql:

select id ,content from id_content where content like '%宋%';

结果 id为1,2,3的记录都出来了,

希望结果:id为2,3的记录

问题:mysql有处理字符串的函数吗?比如过滤html的?

作者: shrimpma   发布时间: 2011-11-14

select id ,content from id_content where content like '宋%';

作者: DongAoYuan   发布时间: 2011-11-14

引用 1 楼 dongaoyuan 的回复:
select id ,content from id_content where content like '宋%';
一楼正解。

作者: ACMAIN_CHM   发布时间: 2011-11-14

引用楼主 shrimpma 的回复:
有表id_cotent

id content
1 <Font Face='宋体' Color='-16777216' Size='10'>你好 </Font>
2 中国宋代是人
3 宋朝灾星
4 woesldfjs
5 我地个身

sql:

select id ,content from id_content where content li……


如果这样呢?

作者: shrimpma   发布时间: 2011-11-14

'%宋%' 这样模糊查询 **宋** 的都能出来 '宋%'这样出来的是 宋**

作者: DongAoYuan   发布时间: 2011-11-14

select id ,content from id_content where content like '宋%' and content not like '%</%';
感觉不太好控制 如果像这样写的话 如果内容里面有“</” 也都被过滤掉

引用 3 楼 shrimpma 的回复:
引用楼主 shrimpma 的回复:
有表id_cotent

id content
1 <Font Face='宋体' Color='-16777216' Size='10'>你好 </Font>
2 中国宋代是人
3 宋朝灾星
4 woesldfjs
5 我地个身

sql:

select id ,content from id_content where conte……

作者: DongAoYuan   发布时间: 2011-11-14

相关阅读 更多