![]() |
![]() |
![]() ![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 276 Pomógł: 3 Dołączył: 22.10.2003 Skąd: Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Mam 4 tabele:
rbx_users z danymi uzytkownika rbx_topics z wątkami forum rbx_forums z forami rbx_subforums z subforami Chcę je złaczyć z sobą tak aby wydobyć informacje o imieniu osoby poprzez złączenie po jej ID o tytule subforum oraz forum poprzez złączenia odpoweidnich id z zapisanymi w wątku ID. Niestety złączenie to nie działa mi porpawnie. Poniższe złączenie
wyrzuca mi NULL-e Kod topic_id forum_id subforum_id author_id topic_kind_id last_post_id active title app_order posts description user_id username name sftitle ftitle 32 83 53 33 0 0 1 wątek testowy należący do subfor 2 0 wątek należący do subforu testowego 33 Gremster Grzegorz Szymanski subforum testowe forum testowe 34 83 0 2 0 0 1 wt należący do f 3 0 tutaj wstaw opis NULL NULL NULL NULL NULL mimo, że osoba o id 2, która powinna się złączyć istnieje w bazie i powinan pojawić sie zamiast NULLi istnieje - czy ktos ma jakiś pomysł dlaczego tak może być? Gdy wykonam takie zapytanie, złączenie jest ok
Ten post edytował Aztech 25.04.2006, 15:23:20 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 276 Pomógł: 3 Dołączył: 22.10.2003 Skąd: Wrocław Ostrzeżenie: (0%) ![]() ![]() |
@spenalzo: Po części masz rację. Doczytałem się w manualu, że
Cytat # Previously, a USING clause could be rewritten as an ON clause that compares corresponding columns. For example, the following two clauses were semantically identical: a LEFT JOIN b USING (c1,c2,c3) a LEFT JOIN b ON a.c1=b.c1 AND a.c2=b.c2 AND a.c3=b.c3 Now the two clauses no longer are quite the same: * With respect to determining which rows satisfy the join condition, both joins remain semantically identical. * With respect to determining which columns to display for SELECT * expansion, the two joins are not semantically identical. The USING join selects the coalesced value of corresponding columns, whereas the ON join selects all columns from all tables. For the preceding USING join, SELECT * selects these values: COALESCE(a.c1,b.c1), COALESCE(a.c2,b.c2), COALESCE(a.c3,b.c3) For the ON join, SELECT * selects these values: a.c1, a.c2, a.c3, b.c1, b.c2, b.c3 With an inner join, COALESCE(a.c1,b.c1) is the same as either a.c1 or b.c1 because both columns will have the same value. With an outer join (such as LEFT JOIN), one of the two columns can be NULL. That column will be omitted from the result. Działa w ten sposób:
Stąd moje zdziwienie początkowe, że nie działało - a w poprzednich wersjach MysQL-a działało bezproblemowo Mam nadzieję, że się ten post komuś przyda |
|
|
![]() ![]() |
![]() |
Aktualny czas: 16.10.2025 - 15:27 |