Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Dwa zapytania w jednym..
xxdrago
post
Post #1





Grupa: Zarejestrowani
Postów: 654
Pomógł: 42
Dołączył: 27.07.2010
Skąd: Jaworzno

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


Witam, mam 2 tabele:
Kod
CREATE TABLE `komentarze` (
  `lp` smallint(6) NOT NULL auto_increment,
  `id` smallint(6) NOT NULL default '0',
  `data` datetime NOT NULL default '0000-00-00 00:00:00',
  `www` text collate utf8_polish_ci NOT NULL,
  `autor` varchar(255) collate utf8_polish_ci NOT NULL default '',
  `email` varchar(100) collate utf8_polish_ci NOT NULL,
  `ip` text collate utf8_polish_ci NOT NULL,
  `przegladarka` text collate utf8_polish_ci NOT NULL,
  `zalogowany` varchar(50) collate utf8_polish_ci NOT NULL,
  `tresc` text collate utf8_polish_ci NOT NULL,
  PRIMARY KEY  (`lp`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci COMMENT='Komentarze' AUTO_INCREMENT=88;
-- --------------------------------------------------------

--
-- Struktura tabeli dla  `newsy_strony`
--

CREATE TABLE `newsy_strony` (
  `id` smallint(6) NOT NULL auto_increment,
  `nazwa` text collate utf8_polish_ci NOT NULL,
  `data` datetime NOT NULL default '0000-00-00 00:00:00',
  `autor` varchar(255) collate utf8_polish_ci NOT NULL default '',
  `tresc` text collate utf8_polish_ci NOT NULL,
  `typ` text collate utf8_polish_ci NOT NULL,
  `link` text collate utf8_polish_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=124;


Normalnie pobieram tak:
Kod
SELECT * FROM  `newsy_strony` WHERE typ =1 ORDER BY `data`


Czy była by możliwość pobrania ilości komentarzy z tabeli `komentarze` ? W jednym zapytaniu zamiast stosować drugie zapytanie:
Kod
SELECT COUNT( * )  FROM komentarze WHERE id =99

0
Myślałem zastosować jakiś JOIN ale nie za bardzo umiem MYSQL (cały czas pogłębiam swoją wiedzę)
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 22.12.2025 - 19:23