Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

How to write this query?

MySql query problem



2:28 pm on Oct 9, 2008 (gmt 0)

5+ Year Member

Hello, guys. On my web project I have this query:

SELECT news_store.id, news_store.src_id,
news_store.title, news_store.message,
news_hosts.host AS host
FROM news_store, news_hosts
WHERE news_hosts.id = news_store.src_id
ORDER BY news_store.id DESC LIMIT 0, 3

Problem is that I need 3 records with 3 DIFFERENT news_store.src_id's, but when I try to put in code "GROUP BY news_store.src_id" after ORDER BY statement I have MySQL error, and if I put this code before ORDER BY I have incorrect result data, coz rows first grouped and only then sorted. Please, help, I'm going mad with this query...


11:41 am on Oct 10, 2008 (gmt 0)

5+ Year Member

SELECT DISTINCT(news_store.src_id), news_store.id,



12:05 pm on Oct 10, 2008 (gmt 0)

5+ Year Member

I've tried this, not working... No, working, but like without (), like SELECT DISTINCT news_store.src_id, news_store.id, ... :((

Featured Threads

Hot Threads This Week

Hot Threads This Month