in the below table i would want the property_id to be unique so that it doesn’t have duplicate values. what is the syntax for this?
CREATE TABLE IF NOT EXISTS `propFeatures` (
`id` bigint(20) NOT NULL auto_increment,
`bedroom` int(10) NOT NULL,
`bathroom` int(10) NOT NULL,
`balcony` int(10) NOT NULL,
`furnished` tinyint(1) NOT NULL,
`property_id` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
You can add
UNIQUEconstraint to yourproperty_idcolumn so that it does not allow duplicates if you want.To check duplicates, you can run this query:
If you want to remove duplicates, check out this post for more info:
MySQL: Remove Duplicate Rows/Records from Table