Hi all!
I have a mysql table that contains IPAddress parts
TABLE `EndPoints`(
`EndPointId` BIGINT(19) UNSIGNED NOT NULL AUTO_INCREMENT ,
`IpPart1` TINYINT(3) UNSIGNED NOT NULL ,
`IpPart2` TINYINT(3) UNSIGNED NOT NULL ,
`IpPart3` TINYINT(3) UNSIGNED NOT NULL ,
`IpPart4` TINYINT(3) UNSIGNED NOT NULL ,
PRIMARY KEY (`EndPointId`))
ENGINE = InnoDB
Each IpPart
contains the byte of an IPAddress byte array.
e.g. address 100.101.102.103
IpPart1 = 101;
IpPart2 = 102;
IpPart3 = 103;
IpPart4 = 104;
Anyway!
I want to do the following :
SELECT EndPointId FROM EndPoints WHERE
IpPart1 = @a AND
IpPart2 = @b AND
IpPart3 = @c AND
IpPart4 = @d;
Then, if the address is not found, add it
INSERT INTO EndPoints (IpPart1,IpPart2,IpPart3,IpPart4)
Values(@a,@b,@c,@d);
Using MySql transactions how will I ensure that only one row is added for each IPAddress?
Thanks!