$sql = "
SELECT DISTINCT article_id, pqdb_articles.*, category_id, category_name, SUBSTRING_INDEX(article_text,' '," . CENTER_COLUMN_PREVIEW . ") AS text
FROM pqdb_articles, pqdb_categories
WHERE article_title LIKE '%$search%' OR article_text LIKE '%$search%'
AND category_id = article_cat ";
DISTINCT not working right....
Moderator: General Moderators
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
DISTINCT not working right....
I am only trying to get one of each article_id. It seems to be getting the whole database instead.
Re: DISTINCT not working right....
It will help greatly if you supply the schema and some sample data when asking database-related questions.
Re: DISTINCT not working right....
It works exactly how it should: selecting unique rows. If you wanted distinct article_id's you shouldn't have put all other fields there.psychotomus wrote: DISTINCT not working right....
I am only trying to get one of each article_id. It seems to be getting the whole database instead.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: DISTINCT not working right....
You probably want to remove the DISTINCT in favor of a GROUP BY article_id
Re: DISTINCT not working right....
you should use group by clause instead of DISTINCT