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)

New User

5+ Year Member

joined:Aug 29, 2008
posts: 3
votes: 0

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)

Full Member

10+ Year Member

joined:Dec 8, 2005
posts: 231
votes: 0

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


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

New User

5+ Year Member

joined:Aug 29, 2008
votes: 0

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members