Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: UNION - nic nie rozumiem!
Forum PHP.pl > Forum > Bazy danych > MySQL
axeld
mam cos takiego:

select 1
union
select 2
union
select 3

kiedy kazdy select uruchamiam osobno to suma rekordow jest 128
ale kiedy wykonam wszystkie 3 selecty z unionami to mam 104 wyniki.

co sie dzieje? powinno tez byc 128 !?



wklejam ten select - jest dosc skomplikowany, ale poszczegolne selecty testowalem i chodza bardzo dobrze, a wspolnie nie.


  1. SELECT pk_user AS user, date(pk_data) AS DATA, 'p' AS trening FROM dart_punkty GROUP BY date(pk_data), pk_user
  2. UNION
  3. SELECT pk_user AS user, date(pk_data) AS DATA, 'b' AS trening FROM dart_bulls GROUP BY date(pk_data), pk_user
  4. UNION
  5. SELECT zeg_user AS user, date(zeg_data) AS DATA, zeg_typ AS trening FROM dart_zegary GROUP BY zeg_sesjaid, zeg_user
  6.  
  7.  
  8. ORDER BY DATA DESC
nospor
pewnie ciezko zajrzec do manuala
http://dev.mysql.com/doc/refman/5.0/en/union.html
?
Cytat
The default behavior for UNION is that duplicate rows are removed from the result. The optional DISTINCT keyword has no effect other than the default because it also specifies duplicate-row removal. With the optional ALL keyword, duplicate-row removal does not occur and the result includes all matching rows from all the SELECT statements.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.