At 01:52, 19990902, Jason wrote:
>I keep getting the error: "Specified key was too long. Max key length is
Jason, you're combining three fields in one key, and the total of the
sizes of those fields is > 256. That's a limitation in MySQL. So you
have to either reduce the size of those fields, remove some of the
fields from the key, or form a key using only portions of those fields.
You probably don't want all of those in the same key. Split them into
four separate keys:
create table the_links
link_id int unsigned not null auto_increment primary key,
url varchar(255) not null,
title varchar(255) not null,
content varchar(255) not null,
/* already have link_id as the PRIMARY KEY */
index index2 (url)
index index3 (title)
index index4 (content)
Note that if you'd kept them as one key, and then did a select like
the following, the index would NOT have been used:
SELECT link_id, title FROM the_links WHERE url LIKE 'http://abc.com'
But if you break up the index into separate pieces, then an index will
be used on that query.