Reputation: 949
I'm trying to build a tag system for my news system. I have finalized a table structure like this:
CREATE TABLE article_tags (
id int(11) unsigned NOT NULL auto_increment,
tag varchar (255) not null,
primary key (id));
CREATE TABLE article_tags_map (
id int(11) unsigned NOT NULL auto_increment,
tag_id int(11) unsigned not null,
article_id int(11) unsigned not null,
primary key (id));
Now I'm just wondering if it would make sense to add a full text index to the tag column in article_tags table ?
$search = $_POST['search_string'];
$search_result = mysql_query ("SELECT *, MATCH(tag) AGAINST ($search) AS score
from article_tags
WHERE MATCH (tag) AGAINST($search)
order by score desc");
Or would I be better off with using LIKE and % wildcard characters ? If I were to use fulltext search, I'm not really sure what threshold should I use for the score ?
Upvotes: 0
Views: 388
Reputation: 3759
Try this.
SELECT *
from article_tags
WHERE tag like '%$search%'
order by tag desc
or
SELECT *
from article_tags
WHERE match(tag) against ('%$search%')
order by tag desc
also take a look to this page where they talk about full text searching: http://devzone.zend.com/26/using-mysql-full-text-searching/
Upvotes: 1