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