seco Posted March 28, 2008 Share Posted March 28, 2008 Hi can i make 2 columns primary key in mysql? or i have to make it using php code by searching? thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/98280-can-i-make-2-columns-primary-key/ Share on other sites More sharing options...
aschk Posted March 28, 2008 Share Posted March 28, 2008 Yes, now would you like to know how? in a table creation statement: CREATE TABLE mytable ( col1 INT UNSIGNED NOT NULL, col2 INT UNSIGNED NOT NULL, PRIMARY KEY (col1,col2) ) or after table creation ALTER TABLE mytable ADD PRIMARY KEY (col1,col2) Quote Link to comment https://forums.phpfreaks.com/topic/98280-can-i-make-2-columns-primary-key/#findComment-502979 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.