Segmentfault在文章编辑界面即有用到标签,那么这个是如何实现的呢?segmentfault
经过最爱的stackoverflow,找到了一些方法,其中用到的最多的一种解决方案以下:spa
简单的表结构code
首先增长一个Tag表,用来存储你的标签图片
涉及到的查询伪语句table
select id from tag_table where Tag like %Tag%
insert into bind_table (Tag, ObjectId) values (tag_id, object_id)
select b.ObjectId from bind_table b, tag_table t where t.Tag like %Tag% and b.Tag = t.Tag
select b.ObjectId from bind_table b, tag_table t where (t.Tag like %Tag% or b.Tag = t.Tag or ...) and b.Tag = t.id group by b.ObjectId having count(b.ObjectId) = Tags.length
就先写这么多了,玩去咯class