Hi

You are wrong.

Just try for example:

 create table test(
                        pk1 int not null,
                        pk2 int not null,
                        primary key(pk1,pk2)
                );

Regards

____________________________________
Daniel Łaś
e-direct Polska sp. z o.o.
WWW: http://www.e-direct.pl
E-mail: [EMAIL PROTECTED]
45-072 Opole ul. Reymonta 45
tel. +48 77 44 26 073
fax. +48 77 44 26 074

> -----Original Message-----
> From: Brendin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 12, 2001 7:37 PM
> To: [EMAIL PROTECTED]
> Subject: primary key based on unique value for two columns
>
>
> I would like to have a table that has a primary key defined on a
> combination of two columns in the table.  In other words a unique key
> based upon the values in two columns.
>
> I don't think I am able to do this in mysql.  I think you can only have
> a primary key on one column and not on a combination of columns.  If I
> am wrong please correct me.
>
> I am looking for work arounds.  I have thought of one.  That would be to
> concatenate the columns and use a field terminator such as a - to
> separate the values or (columns) in the single column.  Then you could
> use string functions to parse the columns.  Ex:
>
> For column 1 in concatenated column
> left( ColumnName, (instr( ColumnName, '-') - 1) )
>
> For column 2 in concatenated column
> Substr (ColumName, (instr ( ColumnName, '-') + 1) , length(ColumnName)-
> (instr ( ColumnName, '-') + 1)  )
>
> Is there any other way to do this?
>
>
> ---------------------------------------------------------------------
> 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