Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Polaczenie 2 zapytan, 2 x count :|
orson
post 7.12.2004, 21:37:28
Post #1





Grupa: Zarejestrowani
Postów: 548
Pomógł: 2
Dołączył: 19.07.2003

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


witam ...

mam takie 2 zapytania:
  1. SELECT count(t1.PersonID) AS zaproszeni, t1.PersonID, t1.Fname, t2.Fname
  2. FROM sys_persons AS t1, sys_persons AS t2 WHERE t1.PersonID = t2.InvitedBy
  3. GROUP BY t1.PersonID

  1. SELECT count(DISTINCT t2.DocID) AS prace, t1.PersonID, t1.Fname
  2. FROM sys_persons AS t1, sys_docs AS t2 WHERE (t1.PersonID = t2.AuthorID) AND t1.PPCredit != 0
  3. GROUP BY t1.PersonID

czy da sie je polaczyc w 1 questionmark.gif rozwiazanie z 2 zapytaniami jest zle ... poniewaz zapytania moga zwracac rozna ilosci wierszy ... moze byc problem z laczeniem wynikow ... pobierane sa te same dane ale inny count ... probowalem z joinami [left, right, cross. outer] ale nie chce mi wyjsc ... czy polaczenie tego jest mozliwe questionmark.gif

aha... mysql w wersji 4.0.x ... bez podzapytan ...

pozdrawiam


--------------------
Computer games don't affect kids; I mean if <span style="font-weight: bold;">Pac Man</span> affected us as kids,we would all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music.
Go to the top of the page
+Quote Post
bigZbig
post 9.12.2004, 15:17:50
Post #2





Grupa: Zarejestrowani
Postów: 740
Pomógł: 15
Dołączył: 23.08.2004
Skąd: Poznań

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


Wyprobuj
  1. SELECT count(t1.PersonID) AS zaproszeni, t1.PersonID, t1.Fname, t2.Fname, count(DISTINCT t2.DocID) AS prace, t1.PersonID
  2. FROM sys_persons AS t1, sys_persons AS t2, sys_persons AS t3
  3. WHERE t1.PersonID = t2.InvitedBy AND t1.PersonID = t3.AuthorID AND t1.PPCredit != 0
  4. GROUP BY t1.PersonID


Ten post edytował bigZbig 9.12.2004, 15:18:07


--------------------
bigZbig (Zbigniew Heintze) | blog.heintze.pl
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 - 07:46