Is it possible to have a unique constraint such that one particular column has a value only once?
For instance
-----------------------
name | pri
Here is a workaround which might suit your needs. Consider the following table definition and unique constraint:
CREATE TABLE prices
(
id int NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
price int,
default varchar(255)
)
ALTER TABLE prices ADD UNIQUE idx (id, name, default);
In your app layer, when you INSERT records when default is FALSE, always leave the id column NULL. This will cause MySQL to always add a unique value for the id, so that duplicate values for name and default may be entered (i.e. a default value of FALSE may occur multiple times for a given name).
However, when you INSERT a record with default being TRUE, you should always use the same id value. This will ensure that a given name can only appear once as TRUE.