Hi everyone,
I have a mysql query which I am trying to select distinct information with.
Here is the query
My problem is that I am not getting distinct newsId's. I have a feeling it is because the entire row is unique to the query. Is there a way I could make the query also only grab a newsId once.Code:SELECT DISTINCT news.newsId, news.headline, news.posted, news.article, authors.authorName, authors.authorEmail, paper.paperDesc, photo.photoLevel, photo.photoType, photo.photoDesc FROM news, authorNews, authors, paperNews, paper, photo, sectionNews, sections WHERE news.newsId=photo.photoNewsId AND photo.photoLevel=1 AND news.newsId=authorNews.newsId AND authorNews.authorId=authors.authorId AND news.newsId=paperNews.newsId AND paperNews.paperId=paper.paperId AND news.newsId=sectionNews.newsId AND sectionNews.sectionId=1 AND (paper.paperId=1 OR paper.paperId=2)
I.E.
currently it pulls out this
I want to be able to pull out one newsId=1 and pull out the newsId=2 also.Code:--------------------------------------- | News Id | Other Column Info | --------------------------------------- | 1 | some info | | 1 | some info | | 1 | some info | | 2 | some info | ---------------------------------------
Is this possible?
I know I could loop through the fetching ignoring the non-unique rows but for efficiency I would like to only grab what I need.
Thanks,
Nick











Bookmarks