homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

How to write this query?
MySql query problem

 2:28 pm on Oct 9, 2008 (gmt 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)

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



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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved