I am having trouble selecting first photo (thumb_filename) and date added (date_added) on every unique article. Every unique article is a gallery for itself.
I am beginner in MySQL, so hope someone could help.
CREATE TABLE IF NOT EXISTS `photographs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`article_id` int(11) NOT NULL,
`thumb_filename` varchar(255) NOT NULL,
`full_filename` varchar(255) NOT NULL,
`date_added` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `article_id` (`article_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=31 ;
I know to use SELECT thumb_filename, date_added FROM photographs and than to filter this out using PHP. I don’t know how to set condition for unique article_id…
Untested of course, but this may do the job for you. This isn’t the only way to do it, but it is a straightforward way. It pulls photograph
ids for the earliestdate_addedof eacharticle_idand then uses those to retrieve the filename.