Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Podzapytanie z Limitem
Siner
post 27.01.2008, 17:48:01
Post #1





Grupa: Zarejestrowani
Postów: 159
Pomógł: 6
Dołączył: 2.01.2004

Ostrzeżenie: (0%)
-----


Potrzebuję pobrać rekordy z dwóch tabel z limitem ilości w jednej. Dokładniej chodzi o to, że chcę aby wynik mi zwrócił galerie z kilkoma(trzema) ostatnimi zdjęciami w każdej z nich.
Struktura tabeli ze zdjęciami:
  1. CREATE TABLE `tt_photo` (
  2. `photoId` int(7) NOT NULL AUTO_INCREMENT,
  3. `photoGaleryId` varchar(6) collate utf8_polish_ci NOT NULL,
  4. `photoUrl` varchar(255) collate utf8_polish_ci NOT NULL,
  5. `photoTitle` varchar(255) collate utf8_polish_ci NOT NULL,
  6. `photoFileName` varchar(255) collate utf8_polish_ci NOT NULL,
  7. `photoDate` int(11) NOT NULL,
  8. PRIMARY KEY (`photoId`),
  9. UNIQUE KEY `photoUrl` (`photoUrl`,`photoFileName`)
  10. )

Struktura tabeli galerii:
  1. CREATE TABLE `tt_gallery` (
  2. `galleryId` int(6) NOT NULL AUTO_INCREMENT,
  3. `galleryTitle` varchar(255) collate utf8_polish_ci NOT NULL,
  4. `galleryUrl` varchar(255) collate utf8_polish_ci NOT NULL,
  5. PRIMARY KEY (`galleryId`),
  6. UNIQUE KEY `galleryTitle` (`galleryTitle`)
  7. )


Na razie wykombinowałem coś takiego, ale nie jest to o co mi chodzi.
  1. SELECT *
  2. FROM tt_gallery AS g
  3. LEFT JOIN (SELECT * FROM tt_photo AS p LIMIT 3 ) AS c ON g.galleryId = p.photoGaleryId;


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 06:44