Struktura tabeli ze zdjęciami:
CREATE TABLE `tt_photo` ( `photoId` int(7) NOT NULL AUTO_INCREMENT, `photoGaleryId` varchar(6) collate utf8_polish_ci NOT NULL, `photoUrl` varchar(255) collate utf8_polish_ci NOT NULL, `photoTitle` varchar(255) collate utf8_polish_ci NOT NULL, `photoFileName` varchar(255) collate utf8_polish_ci NOT NULL, `photoDate` int(11) NOT NULL, PRIMARY KEY (`photoId`), UNIQUE KEY `photoUrl` (`photoUrl`,`photoFileName`) )
Struktura tabeli galerii:
CREATE TABLE `tt_gallery` ( `galleryId` int(6) NOT NULL AUTO_INCREMENT, `galleryTitle` varchar(255) collate utf8_polish_ci NOT NULL, `galleryUrl` varchar(255) collate utf8_polish_ci NOT NULL, PRIMARY KEY (`galleryId`), UNIQUE KEY `galleryTitle` (`galleryTitle`) )
Na razie wykombinowałem coś takiego, ale nie jest to o co mi chodzi.
SELECT * FROM tt_gallery AS g LEFT JOIN (SELECT * FROM tt_photo AS p LIMIT 3 ) AS c ON g.galleryId = p.photoGaleryId;