SQL-Query Abfrage limitieren
Eingetragen von mathias2711 (62)
am 24.09.2009 - 09:14 Uhr in
am 24.09.2009 - 09:14 Uhr in
Hi,
wie kann ich in diesem SQL-Query die Ausgabe auf 3 Benutzernamen pro Monat limitieren??
select
(select users.name FROM users WHERE uid = content_field_foto_fotografen.field_foto_fotografen_uid) AS username,
(select users.uid FROM users WHERE uid = content_field_foto_fotografen.field_foto_fotografen_uid) AS userid,
(select users.picture FROM users WHERE uid = content_field_foto_fotografen.field_foto_fotografen_uid) AS userpicture,
(select YEAR(content_type_photo.field_foto_termin_datum_value) FROM content_type_photo WHERE content_type_photo.nid = content_field_foto_fotografen.nid) AS year,
(select MONTH(content_type_photo.field_foto_termin_datum_value) FROM content_type_photo WHERE content_type_photo.nid = content_field_foto_fotografen.nid) AS month,
count(*) AS anzahl
FROM
content_field_foto_fotografen
WHERE
((select node.status from node where node.nid = content_field_foto_fotografen.field_foto_fotografen_uid) <> 0)
GROUP BY
content_field_foto_fotografen.field_foto_fotografen_uid,
(select MONTH(content_type_photo.field_foto_termin_datum_value) FROM content_type_photo WHERE content_type_photo.nid = content_field_foto_fotografen.nid),
(select YEAR(content_type_photo.field_foto_termin_datum_value) FROM content_type_photo WHERE content_type_photo.nid = content_field_foto_fotografen.nid)
ORDER BY
year DESC,
month DESC,
count(*) DESC
Gruss udn Danke
Mathias
- Anmelden oder Registrieren um Kommentare zu schreiben
LIMIT
am 24.09.2009 - 09:47 Uhr
wie kann ich in diesem SQL-Query die Ausgabe auf 3 Benutzernamen pro Monat limitieren??
Prinzipiell mit
LIMIT
.Woher kommt diese Abfrage denn?
select
(select users.name
FROM users
WHERE uid = content_field_foto_fotografen.field_foto_fotografen_uid
LIMIT 3) AS username,
(select users.uid
FROM users
WHERE uid = content_field_foto_fotografen.field_foto_fotografen_uid
LIMIT 3) AS userid,
(select users.picture
FROM users
WHERE uid = content_field_foto_fotografen.field_foto_fotografen_uid
LIMIT 3) AS userpicture,
(select YEAR(content_type_photo.field_foto_termin_datum_value)
FROM content_type_photo
WHERE content_type_photo.nid = content_field_foto_fotografen.nid) AS year,
(select MONTH(content_type_photo.field_foto_termin_datum_value)
FROM content_type_photo
WHERE content_type_photo.nid = content_field_foto_fotografen.nid) AS month,
count(*) AS anzahl
FROM content_field_foto_fotografen
WHERE
((select node.status from node where node.nid = content_field_foto_fotografen.field_foto_fotografen_uid) <> 0)
GROUP BY
content_field_foto_fotografen.field_foto_fotografen_uid,
(select MONTH(content_type_photo.field_foto_termin_datum_value)
FROM content_type_photo
WHERE content_type_photo.nid = content_field_foto_fotografen.nid),
(select YEAR(content_type_photo.field_foto_termin_datum_value)
FROM content_type_photo
WHERE content_type_photo.nid = content_field_foto_fotografen.nid)
ORDER BY
year DESC,
month DESC,
count(*) DESC
Schön und performant ist jedoch anders.
hth,
Stefan
--
sei nett zu Deinem Themer
Tipp: Beachte die Verhaltensregeln des DrupalCenter.
ist nur für intere zwecke.
am 24.09.2009 - 10:31 Uhr
selbst gebaut...
ist nur für intere zwecke. sie wird vll 10 / woche ausgeführt.. daher muss sie nicht perforamant sein und mit limit geht es leider nicht.