Tim Cowan wrote:
> 
> Hi
> 
> Is it possible to use 2 or more fields to become the primary key.  I have a
> table
> 

Yes

> CREATE TABLE tmptraining (
>   rowid int(10) unsigned NOT NULL auto_increment,
>   sid char(32) NOT NULL default '',
>   expiry date NOT NULL default '0000-00-00',
>   arenaid tinyint(1) unsigned NOT NULL default '0',
>   time time NOT NULL default '00:00:00',
>   date date NOT NULL default '0000-00-00',
>   equip enum('Y','N') NOT NULL default 'N',
>   PRIMARY KEY  (rowid)
> )
> 
> and I want to constrain the information on four fields; arena, time, date
> and sid.  That way if someone clicks the refresh or reload button it will
> not add another row, if all FOUR of the fields have the same value as
> another row.  Is there a way to do this?
>

Just create an "unique index" on these fields (arena, time, date, sid).
See 'alter table' command in MySQL manual.
 
> Thanks
> 
> Tim
> 

Regards
--
Joseph Bueno
NetClub/Trader.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to