Hello,
I have a table structure like so:
The ID field is actually a 40-char GUID rather than a traditional numeric auto-inc. I am wondering what is the most efficient way to query this table to find the next and previous consecutive records given a specific ID.Code:CREATE TABLE `photos` ( `id` varchar(40) NOT NULL, `date_added` timestamp NOT NULL default CURRENT_TIMESTAMP, `date_updated` timestamp NULL default NULL, `is_active` tinyint(1) unsigned NOT NULL default '1', `review` tinyint(1) unsigned NOT NULL default '1', `account` varchar(40) NOT NULL, `vote_count` int(10) unsigned NOT NULL default '0', `vote_up` int(10) unsigned NOT NULL default '0', `category` varchar(40) NOT NULL, `file_img` varchar(40) NOT NULL, `file_original_img` varchar(40) NOT NULL, PRIMARY KEY (`id`), KEY `review` (`review`), KEY `account` (`account`), KEY `is_active` (`is_active`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
The original parameters would be.Code:SELECT * FROM photos WHERE is_active=1 AND review=0 AND category={some category GUID} ORDER BY date_added DESC









Bookmarks