table creation

Codes here !

Moderators: macek, egami, gesf

klustrophobic24
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Jan 09, 2014 7:18 am

table creation

Postby klustrophobic24 » Thu Jan 09, 2014 7:25 am

hi guys. newbie here.

i created the table below:

Code: Select all

CREATE TABLE IF NOT EXISTS `persons4` (
  `P_Id` int(11) NOT NULL AUTO_INCREMENT,
  `LastName` varchar(255) NOT NULL,
  `FirstName` varchar(255) DEFAULT NULL,
  `Address` varchar(255) DEFAULT NULL,
  `City` varchar(255) DEFAULT NULL,
  UNIQUE KEY `uc_PersonID` (`P_Id`,`LastName`,`FirstName`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;


however when i tried to enter a value via phpadmin, it still accepts duplicate rows for all fields except for the P_Id column.

what i'm trying to do is if someone tries to insert a row in that table, they should be unique.

should this be done via php script to check first if there is an existing field on that table or should this be check already via the mysql db? thanks.

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 4 guests