How can I make a combination of 2 columns unique in mysql? for example I want to have only one business in one town in my table.
You can use something like: CREATE TABLE business ( businessname VARCHAR(100), town VARCHAR(100), . . . . PRIMARY KEY (businessname, town) ); Code (markup):
Try this: ALTER TABLE business ADD PRIMARY KEY (businessname, town); Code (markup): If you have already defined a primary key for the table, then use this command first: ALTER TABLE business DROP PRIMARY KEY; Code (markup):