Hi,

> I have a table with peoples names in 3 different languages.
> Fields are like: id, surname_english, name_english, surname_original,
> name_original, surname_greek, name_greek.
> What I want is to check if a person has been entered twice in that table.
> The key is ID but I can't have any other field unique, as names and
> surnames are not unique.
> I only want the combination of two fields of the same language to be unique.
> How can I check this?
> Any possible solution?

You  can  always  define  an  UNIQUE  index  on the required
fields. Something like this:

mysql> select * from nametest;
+----+--------+-----------+--------+-----------+
| id | name_1 | surname_1 | name_2 | surname_2 |
+----+--------+-----------+--------+-----------+
|  1 | A      | A         | E      | T         |
|  2 | B      | B         | S      | F         |
|  3 | C      | C         | E      | T         |
+----+--------+-----------+--------+-----------+
3 rows in set (0.00 sec)

mysql> alter table nametest add unique index sn1(name_1, surname_1);
Query OK, 3 rows affected (0.02 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> alter table nametest add unique index sn2(name_2, surname_2);
ERROR 1062: Duplicate entry 'E-T' for key 3

The  creation  of  the  first  index went OK as there are no
duplicate  entries.  The  second  one  reported  a duplicate
entry.  Once  created  these  indices  will not allow you to
enter duplicates.


Take care,
Aleksandar


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to