[thelist] mysql - unique index combos

Norbert E. Wagner n.wagner at tiscali.it
Tue Feb 22 18:18:42 CST 2005


At 15.41 22/02/2005 -0800, you wrote:
>Is there a way to declare a unique index on these two fields, such that 
>when someone tries to enter a combination that is already in the table it 
>doesn't enter a duplicate entry?  ...or do I need to put this logic in my 
>application instead?

try somthing like this:
CREATE TABLE yourTable(
         ProjectID INT UNSIGNED NOT NULL,
         DocumentID INT UNSIGNED NOT NULL,

         PRIMARY KEY(ProjectID, DocumentID)
);

Norbert



More information about the thelist mailing list