phpbar.de logo

Mailinglisten-Archive

AW: [dbs] Problem mit 2 SELECTs

AW: [dbs] Problem mit 2 SELECTs

Sebastian Tobias Mendel genannt Mendelsohn lists at sebastianmendel.de
Don Sep 11 13:21:28 CEST 2003


>    SELECT news.*,
>           news_kategorien.name,
>           news_kategorien.farbe AS katfarbe,
>           user.userid,
>           user.nickname,
>           user.farbe,
>           COUNT(meinung_artikel.forumid) AS newsposts,
>           bilder.thumbURL,
>           news_bilder.thumbURL,
>           COUNT(vote.vnote) AS Anzahlvonvnote,
>           SUM(vote.vnote) AS Summevonvnote
>      FROM news
> LEFT JOIN news_kategorien
>        ON news.newskatID = news_kategorien.id
> LEFT JOIN user
>        ON news.autorID = user.userid
> LEFT JOIN meinung_artikel
>        ON news.id = meinung_artikel.forumid
> LEFT JOIN bilder
>        ON news.thumbID = bilder.id
> LEFT JOIN news_bilder
>        ON news.thumbID = news_bilder.id
> LEFT JOIN vote
>        ON news.id = vote.newsid
>  GROUP BY news.id
>    HAVING news.online = 1
>       AND news.fertig = 1
>       AND news.gesperrt = 0
>  ORDER BY news.online_date DESC


fäält mir noch was ein, statt dem having ein wehre könnte das query 
eventuell beschleunigen, also:

    SELECT news.*,
           news_kategorien.name,
           news_kategorien.farbe AS katfarbe,
           user.userid,
           user.nickname,
           user.farbe,
           COUNT(meinung_artikel.forumid) AS newsposts,
           bilder.thumbURL,
           news_bilder.thumbURL,
           COUNT(vote.vnote) AS Anzahlvonvnote,
           SUM(vote.vnote) AS Summevonvnote
      FROM news
LEFT JOIN news_kategorien
        ON news.newskatID = news_kategorien.id
LEFT JOIN user
        ON news.autorID = user.userid
LEFT JOIN meinung_artikel
        ON news.id = meinung_artikel.forumid
LEFT JOIN bilder
        ON news.thumbID = bilder.id
LEFT JOIN news_bilder
        ON news.thumbID = news_bilder.id
LEFT JOIN vote
        ON news.id = vote.newsid
     WHERE news.online = 1
       AND news.fertig = 1
       AND news.gesperrt = 0
  GROUP BY news.id
  ORDER BY news.online_date DESC


-- 
Sebastian Mendel

www.sebastianmendel.de
www.tekkno4u.de
www.nofetish.com


php::bar PHP Wiki   -   Listenarchive