Hello all,
This is one of these things that I am uncertain can be solved with ordinary SQL, but any suggestions are appreciated!
I have two tables with a one-to-many relationship. One record in the main table can be linked with none, one or more records in the secondary table.
For most main records there are no corresponding secondary records, for a few there is one, and for one in particular, there are two. This latter record is what it is all about.
In my query I have a LEFT JOIN which (naturally) duplicates the record in the main table in order to include both records from the secondary table.
However, I only want a single record from the main table and a value from the first record in the secondary table. Duplicate main table rows give me problems in my overlying application when enforcing constraints.
How do I accomplish this if it is at all possible? I have depleted the possibilities with different kinds of JOINs. I wonder whether it can be solved with a GROUP BY statement.
Fedor Steeman
Geological Museum Copenhagen
Denmark
This is one of these things that I am uncertain can be solved with ordinary SQL, but any suggestions are appreciated!
I have two tables with a one-to-many relationship. One record in the main table can be linked with none, one or more records in the secondary table.
For most main records there are no corresponding secondary records, for a few there is one, and for one in particular, there are two. This latter record is what it is all about.
In my query I have a LEFT JOIN which (naturally) duplicates the record in the main table in order to include both records from the secondary table.
However, I only want a single record from the main table and a value from the first record in the secondary table. Duplicate main table rows give me problems in my overlying application when enforcing constraints.
How do I accomplish this if it is at all possible? I have depleted the possibilities with different kinds of JOINs. I wonder whether it can be solved with a GROUP BY statement.
Fedor Steeman
Geological Museum Copenhagen
Denmark