Hi!

There are many ways, depending on whether you want the database to handle it, or you want your application to handle it.

What you want is a UNIQUE index on surname_original and name_original. Assuming the table already exists:

ALTER TABLE names ADD UNIQUE(name_original,surname_original);

This will ensure that, for every row, the combination of name_original and surname_original is unique for the table, assuming that the table is called "names".

To do it at the app level, you could either check before each insertion (no good unless you're willing to lock the table while you check for existance - not recommended) or add another column that contains a unique hash (a bit quicker in terms of database operations, but probably not as nice as the DB-side solution).

Hope this helps!

Regards,

Chris

fr0g wrote:

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?





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



Reply via email to