Hallo zusammen,
ich stehe hier gerade etwas auf de Schlauch oO. Für ein Projekt auf MySQL-Basis (V5) möchte ich in einem Subselect nach dem neuesten Datum (timestamp) sortieren - bisher dachte ich immer, das würde mit having funktionieren. Tut es aber nicht, ich bekomme keinen Datensatz zurück.
Ohne den Filter auf created (HAVING max(created
)) bekomme ich zuviele Daten; hier speichere ich zum Nachvollziehen jede Statusänderung.
Die Query schaut im Moment so aus:
SELECT objects
.id
AS id
, 0 AS relevance
FROM (
SELECT id
FROM (
SELECT DISTINCT(object
)
FROM \_order\_prop\_status
AS valuetable
WHERE (value
IN (
SELECT DISTINCT(object
)
FROM \_status\_object\_prop\_status
AS valuetable
WHERE (value
= 11) HAVING max(created
))))
AS tmptable
LEFT JOIN \_order
AS objects
ON objects
.id
=tmptable
.object
WHERE NOT ISNULL(objects
.id
) AND ISNULL(objects
.deleted
)) AS objects
LEFT JOIN \_order\_prop\_date
ON (\_order\_prop\_date
.object
=objects
.id
AND ISNULL(\_order\_prop\_date
.deleted
)) ORDER BY \_order\_prop\_date
.value
DESC LIMIT 20
Hat jemand eine Idee für mich?
Gruß,
Manu