phpbar.de logo

Mailinglisten-Archive

[php] [1/2 OT] Mysql Query

[php] [1/2 OT] Mysql Query

Martin Walper martin at klickhere.com
Mon Mai 7 09:56:06 CEST 2007


Sebastian Mendel schrieb:
> SELECT * FROM (
>
>>> SELECT
>>> 	l.indate,
>>> 	l.lcbid,
>>> 	l.votes,
>>> 	MAX(l2.votes) AS maxvotes
>>> FROM
>>> 	lcb_vote AS l
>>> LEFT JOIN
>>> 	lcb_vote AS l2
>>> ON
>>> 	l.indate = l2.indate
>>> GROUP BY
>>> 	l.indate,
>>> 	l.lcbid
>>> HAVING	maxvotes = l.votes
>>>       
>
> )
>
> ORDER BY indate DESC
> LIMIT 12
>
>   
denke habe es nun hin bekommen:

SELECT v.indate, v.lcbid, v.maxvotes FROM
(
    SELECT
        l.indate,
        l.lcbid,
        l.votes,
        MAX(l2.votes) AS maxvotes
    FROM
        lcb_vote AS l
    LEFT JOIN
        lcb_vote AS l2
    ON
        l.indate = l2.indate
    GROUP BY
        l.indate,
        l.lcbid
    HAVING    maxvotes = l.votes
)
AS v
GROUP BY v.indate
ORDER BY v.indate DESC
LIMIT 12

vielen Dank an alle

MfG
Martin Walper

-- 
Martin Walper
martin at klickhere.com

Webdesign & Hosting
http://www.klickhere.com
Tel.:(0034) 96 583 4119


php::bar PHP Wiki   -   Listenarchive