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

Re: Beginner question


Assuming that you have a table called 'test' where there are three columns
'a', 'b' and 'c'.

Now you have 'a'+'b' as unique but neither only 'a' nor 'b'.

To specify that, define a and b both combined as primary key for the table,
as in the following statement:

CREATE TABLE `test` (
`a` TINYINT NOT NULL,
`b` TINYINT NOT NULL,
`c` TINYINT NOT NULL,
PRIMARY KEY (`a`, `b`)
);
       
This would achieve exactly what you want,

With regards,
Kundan


On 11/28/01 10:18 PM, "Etienne Marcotte" <emarcott@xxxxxx> wrote:

> When creating a table, can we specify that the combinaison of two fields
> needs to be unique but each of those two fields may have duplicates,
> just not both the same?
> 
> Can we have a required attribute on one of two fields? I have
> phone_line_french and phone_line_english, i require one of those two to
> be filled (or both). I can check that in my script, just asking if we
> can do it in mySQL
> 
> Regards,
> 
> Etienne


---------------------------------------------------------------------
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 <mysql-thread92871@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



This mailing list archive is a service of Copilot Consulting.