Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> SELECT
Athlan
post
Post #1





Grupa: Developerzy
Postów: 823
Pomógł: 12
Dołączył: 18.12.2005

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


Ajjj... dawno nie pisałem smile.gif Więc witam smile.gif

Mój problem polega na tym, że potrzebuje wybrać dane z drugiej tabeli, jednakże LEFT JOIN tu zawodzi.

Posiadam tabele:
  1. --
  2. -- Struktura tabeli dla `notes`
  3. --
  4.  
  5. CREATE TABLE `notes` (
  6. `note_id` int(11) NOT NULL AUTO_INCREMENT,
  7. `note_blog` int(11) NOT NULL,
  8. `note_author` int(11) NOT NULL,
  9. `note_time` int(11) NOT NULL,
  10. `note_update` int(11) NOT NULL,
  11. `note_title` varchar(255) NOT NULL,
  12. `note_rewrite` varchar(255) NOT NULL,
  13. `note_text` longtext NOT NULL,
  14. `note_active` enum('y','n') NOT NULL DEFAULT 'n',
  15. `note_comments` enum('y','n') NOT NULL DEFAULT 'y',
  16. PRIMARY KEY (`note_id`),
  17. KEY `note_rewrite` (`note_rewrite`),
  18. KEY `note_blog` (`note_blog`),
  19. KEY `note_time` (`note_time`),
  20. KEY `note_author` (`note_author`),
  21. KEY `note_active` (`note_active`),
  22. KEY `note_update` (`note_update`)
  23. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
  24.  
  25. -- --------------------------------------------------------
  26.  
  27. --
  28. -- Struktura tabeli dla `tags`
  29. --
  30.  
  31. CREATE TABLE `tags` (
  32. `tag_name` varchar(255) NOT NULL,
  33. `tag_note` int(11) NOT NULL,
  34. `tag_blog` int(11) NOT NULL,
  35. PRIMARY KEY (`tag_name`,`tag_note`),
  36. KEY `tag_blog` (`tag_blog`)
  37. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Przy zapytaniu:
  1. SELECT * FROM notes

chciałbym pobrać również wszystkie rekordy z tabeli tags gdzie tag_note = note_id przypisane do wybieranego rekordu.

LEFT JOIN pobierze tylko jeden tag (rekord z tabeli tags), a chciałbym otrzymać wszystkie w jednym zapytaniu. Jakieś sugestie? Dzięki za odpowiedź smile.gif

Pozdrawiam, Athlan


--------------------
Portfolio: Vgroup.pl | athlan.pl | Test.php.pl - sprawdź się z wiedzy o PHP i ułóż własne pytania!
Pomogłem? Kliknij pod postem.
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 20.08.2025 - 04:43