Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [mysql] pobieranie danych z 2 tabeli na podstawie 1
Lejto
post
Post #1





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

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


Chcę pobrać informacje w jednym zapytaniu z 2 tabel, a dokładnie chcę pobrać liczbę rekordów z 2 tabeli na podstawie id z 1 tabeli
zorbiłem coś takiego
  1. $sql = $this->sql->query('select categories.id_categories,category from categories INNER JOIN videos ON categories.categories_id = videos.id_videos');

ale nie chce działać
tabele
  1.  
  2. CREATE TABLE IF NOT EXISTS `categories` (
  3. `category` text collate utf8_unicode_ci NOT NULL,
  4. `id_categories` int(11) NOT NULL AUTO_INCREMENT,
  5. PRIMARY KEY (`id_categories`)
  6. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=25 ;
  7.  
  8.  
  9. CREATE TABLE IF NOT EXISTS `videos` (
  10. `video` text collate utf8_unicode_ci NOT NULL,
  11. `description` text collate utf8_unicode_ci NOT NULL,
  12. `title` text collate utf8_unicode_ci NOT NULL,
  13. `cover` varchar(50) collate utf8_unicode_ci NOT NULL DEFAULT 'okladki/',
  14. `data` datetime NOT NULL,
  15. `category` int(11) NOT NULL,
  16. `last_viev` datetime NOT NULL,
  17. `views` int(11) NOT NULL,
  18. `videos_id` int(11) NOT NULL AUTO_INCREMENT,
  19. PRIMARY KEY (`videos_id`)
  20. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;

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.08.2025 - 15:50