From: Martin B. Jespersen Date: March 22 1999 2:23pm Subject: How to make a joint primary key of two or more fields List-Archive: http://lists.mysql.com/mysql/770 Message-Id: <36F6526B.B47E8499@IconMedialab.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Well there it is, all in the subject. I can't figure out how to make two fields function as a single primary key and thus have an unique check on them both but not seperately. This might be a big RTFM to me, but i haven't been able to find documentation taht i understand about it.. all i found was: A PRIMARY KEY can be a multiple-column index. However, you cannot create a multiple-column index using the PRIMARY KEY key attibute in a column specification. Doing so will mark only that single column as primary. You must use the PRIMARY KEY(index_col_name, ...) syntax. it says i have to use PRIMARY KEY(index_col_name, ...), so does the collumns i use for the joint primary have to be indexes? lets say i have a table with two int's and one varchar and i want all three to be the primary key together. i figured i could just do: alter table my_tbl ADD PRIMARY KEY (int_col1,int_col2,varchar_col1); but somehow it didn't do the trick for me (i think)... i am out where i have a hard time reaching the bottom, anyone care to get me to shore? :-) Please bend that syntax in neon for me, and please include an example. :-) -- Martin B. Jespersen Technical Project Leader Icon Medialab A/S (http://www.IconMedialab.dk) E-Mail: Martin@stripped Mail: Havnegade 39, DK-1058 Copenhagen K Voice: (+45) 7023-1001 Fax: (+45) 33320209