I have three tables "items", "dates", "membership", and "collection".
"items" joins "dates" on Id, a unique identifier. "collection" defines certain collections of "items", each has a unique collection_id. So "membership" has an Id field, and a collection_id field. Each "items" record can belong to multiple "collection"s.
The query:
Code:
SELECT i.Id, i.Name, d.Date from items as i LEFT JOIN dates as d on (i.Id = d.Id) LEFT JOIN membership as m on (i.Id = m.Id) LEFT JOIN collection as c on (m.collection_id = c.collection_id)
returns the expected results, but I need to only get ONE of each "items" record, regardless of how many memberships it has. The membership record it returns is unimportant. I tried DISTINCT, but I'm not sure I have the syntax down right, and can't seem to find documentation or a sample that applies to this situation.
In another forum, Stumpy suggested:
Code:
SELECT DISTINCT(i.Id), i.Name, d.Date...
but it didn't work as I had hoped, meaning that it didn't limit it as I needed. Is there any other possible solution?
Also, if this isn't implied by my choice of forum: I have to accomplish this all with the SQL, I can't use ASP/PHP/Perl/anything else to accomplish this.
Thanks much for any help.
D. Mors