I have a primary key in my mysql table that consists of three columns.
CREATE TABLE IF NOT EXISTS `bb_bulletin` (
`OfficeCode` int(5) NOT NULL,
`IssuerId` int(11) NOT NULL,
`BulletinDtm` datetime NOT NULL,
`CategoryCode` varchar(4) NOT NULL,
`Title` varchar(255) NOT NULL,
`Content` text NOT NULL,
PRIMARY KEY (`OfficeCode`,`IssuerId`,`BulletinDtm`),
UNIQUE KEY `U_IssuerId` (`IssuerId`,`OfficeCode`,`BulletinDtm`),
UNIQUE KEY `U_CategoryCode` (`CategoryCode`,`OfficeCode`,`IssuerId`,`BulletinDtm`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Is there a shorthand method for selecting an entry for a given primary key value.
I tried.
SELECT * FROM `bb_bulletin` WHERE PRIMARY = '20001-1-2011-01-07 14:04:40'
Instead of a long manual method,
SELECT * From bb_bulletin WHERE OfficeCode = 20001 AND IssuerId = 1 AND BulletinDtm = 2011-01-07 14:04:40
What is the standard when working with php and compound keys in your table. Note. I do not want to add auto-increment keys to my tables to solve this problem. If this is not possible, I will just pass the three restrictions in my url.
source
share