MySQL TEXT datatype INDEX

admin

Administrator
Staff member
A question about indexing fileds for better searching results.

I have a 4 column table, files

title(VARCHAR), date(DATE), path(VARCHAR), content(TEXT)

content is going to contain the content of an HTML file. It could contain large blocks of text. the search will be something like

SELECT title, content FROM files WHERE content LIKE '%searchterm%' ORDER BY date

Now I know I need to index the content column, but MySQL wont let me make an index on the field. It returns:

MySQL said: BLOB column 'content' used in key specification without a key length

So I try to add a length to the field and I get the following error:

ALTER TABLE archive_db CHANGE content
content TEXT (50000)
MySQL said: You have an error in your SQL syntax near '(50000) ' at line 1

Any ideas on how to set this up?
 
Back
Top