On Mon, 19 Feb 2001, Chris Aitken wrote:

> Hi Everyone.
> 
> Just a quick question I worked out once before on my lonseome and the mysql 
> manual, but it was longer ago than yesterday and it a blur how I did it.
> 
> What I need to do is..... I have a table, and in that table there are 
> several fields which need to be unique. What do I need to do to make other 
> fields within a table so that it rejects any duplicates.
> 
> If for instance, I have a field called 'job_number' in a table called 
> 'jobs' and it is 'varchar(50)' and I want to make it so that no duplicates 
> are allowed, what command should I issue ?
> 

You can add UNIQUE INDEX to the columns.

create UNIQUE  INDEX job_number_idx on jobs (jobs_number(10));

For CHAR and VARCHAR columns, indexes can be created that use only part of
a column, using col_name(length) syntax. 

Or make the column primary key. see the documentation 8-)). 

--ilham--
> 
> Thanks
> 
> 
> Chris
> 
> 
> ---------------------------------------------------------------------
> 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
> 


---------------------------------------------------------------------
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