Manickus Manickus - 1 year ago 97
MySQL Question

Unique value in field for specific field in sql

I have to create a new table in

, but I have a problem.

I want to have a unique value in one field but only for a specific field in same table, similar like a one to many.


And now I want to have ID_Order unique for the table, and ID_Supplier_Order only for specific Supplier. Can I do it in one table, or I have to create a second for Suppliers?

Answer Source

Taken from:

Add unique constraint to combination of two columns

CREATE UNIQUE INDEX uq_yourtablename
  ON dbo.yourtablename(column1, column2);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download