[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PHPwestoz] [OT] MySQL UNIQUE INDEX



Timothy,

If you are wanting to place a limit on the text column, try VARCHAR and limit that.

This means that your sql script would look like

CREATE TABLE library (
ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
Filename TEXT NOT NULL,
Artist TEXT NULL,
Title TEXT NULL,
Album TEXT NULL,
FID VARCHAR(40) NOT NULL,
PRIMARY KEY ID (ID),
INDEX UID (FID)
) TYPE = MyISAM COMMENT ='';

And quickly testing it seems to work

Hope that it helps

Cheers
Mike Fewings

Timothy White wrote:
I know this isn't PHP but hopefully one of you guys will know the answer (and it is for a PHP project)
I am trying to create a table that has a primary key and a unique key based on different columns.
The query is:
CREATE TABLE library (
ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
Filename TEXT NOT NULL,
Artist TEXT NULL,
Title TEXT NULL,
Album TEXT NULL,
FID TEXT(40) NOT NULL,
PRIMARY KEY ID (ID),
INDEX UID (FID)
) TYPE = MyISAM COMMENT ='';
And the error is:
ERROR 1170 (42000): BLOB/TEXT column 'FID' used in key specification without a key length
I can't find anything in the manual that tells me how to get around this.

Thanks

Tim



NOTE: This email contains information which may be confidential or privileged. Its contents remain the property of Mr Michael Fewings. The information is intended solely for the use of the recipient (or legal entity) named above. If you are not the intended recipient and/or purport to be the intended recipient you must not read, use or disseminate the enclosed information. The content and email itself are subject to intellectual property rights and copyrights. If you have received this electronic transmission in error, please notify Mr Michael Fewings by electronic mail immediately. Any opinions expressed are those of the author, not those of any other party. This email does not constitute either offer or acceptance of any contractually binding agreement. Such offer or acceptance must be communicated in writing through other channels.