PDA

View Full Version : show only one record from multiple results


contact318852
11-19-2009, 11:02 PM
Knowing there may be more than one way to acheive this, Im wodnering if the php pundits might point me toward more precise topics to search for a solution.

I created a search and results set of pages in dataassist then manually edited the sql to create a record set based on an inner join of two tables.

member and locations

Each member on the site has one unique member record, but can have many locations records. However on this particular search result I only want to show one record per memberid (the unique index of the join)

So although there may be 6 locations records for memberid 12 I only want to display on one record per memberid

I suspect I should add more code to the record set select statement that defines a count of memberid results, and returns only count # 1 of memberid

does it sound like im on the right train of thought?

Dave Buchholz
11-20-2009, 01:12 AM
you could use "DISTINCT" in your sql statement to return one result or maybe LIMIT or TOP

contact318852
11-20-2009, 09:10 AM
Thank you very much

DISTINCT seems to have solved the issue!

heres my sql in case anyone finds it useful

SELECT DISTINCT *
FROM member, locations
WHERE locations.member_MemberID = member.MemberID

so each record in member is unique, but each member can have many locations records to acheive a search by location, for member I joined the tables in the record set, but came back with multiple results for each member the Suggested use of DISTINCT pulls only one.

thaks so much, Ill explore those other suggestions as well.