PDA

View Full Version : Unique row not column?


david07
02-12-2006, 01:01 PM
I know Mysql is able to prevent duplicates being entered in the one column, via the 'unique' feature.

Is it possible to stop rows of the same values being created.

For example
joining two or more columns in a row, and merging the values into a singular value, upon which the 'unique' feature may work. Or is their more of a simple way of doing this.???

Invoice_ID Products UNIQUE
56 ---------- X --------- 56X
56 ---------- Y --------- 56Y
56 ---------- X --------- 56X
57 ---------- Y --------- 57Y

MetalStorm
02-12-2006, 02:10 PM
What's your Primary Key there?

Sounds like you might need it to be made up of two or more fields.

GJay
02-12-2006, 07:46 PM
Postgres allows:
ALTER TABLE tablename ADD CONSTRAINT constraintname UNIQUE(field1,field2,field3,etc.);

I'd assume MySQL would be somewhat similar