I am trying to develop a small photo cataloging and storage system in PHP / MySQL. Currently my database is structured as follows:
CREATE TABLE `photos` (
`picid` varchar(36) NOT NULL,
`uploaded` varchar(10) NOT NULL,
`picdesc` text NOT NULL,
`views` bigint(20) NOT NULL,
`albumid` varchar(36) NOT NULL COMMENT 'fkey albums',
`uploadedby` varchar(50) NOT NULL COMMENT 'fkey users',
`exif` longtext NOT NULL,
`album_protected` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`picid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
The picid
field is a GUID used as the primary key.
I need help with creating an SQL query that will return the record previous to a passed in picid
and the record next from it too. I think I will need to use two queries, but perhaps someone can tell me otherwise. The records are ordered by uploaded
which is a UNIX TIMESTAMP value.
Hope you can help! Please tell me if you require more info!