A
Allie
Hello all,
I am working with a database which has a main table, and then a few
sub-tables with a one-to-many relationship. As far as I've been able to
figure out, SQL isn't suited to grab *all* the sub-records associated
with a single record in the main table all in one query.
To illustrate my point, let's say in the main table I have a record with
mainID = 1. In my subtable, I have two records each pointing to the
main record with mainID = 1. A SQL join will return two records. What
I want is a single record, with both sub-records appended one after the
other. So I would end up with 'main table records' + 'sub table record
1' + 'sub table record 2'.
I assume that I will have to use VB script to do this, saving the
queries in an array or something like that, and then appending and
outputting from the code itself, not SQL per se. Are there any other
suggestions, or elegant solutions to this problem?
For those who are curious, I am doing this because I work with a
sociologist who needs the data in a flat format (there will be somewhere
around 3000 columns in the end - yuck).
Thanks,
Allie
I am working with a database which has a main table, and then a few
sub-tables with a one-to-many relationship. As far as I've been able to
figure out, SQL isn't suited to grab *all* the sub-records associated
with a single record in the main table all in one query.
To illustrate my point, let's say in the main table I have a record with
mainID = 1. In my subtable, I have two records each pointing to the
main record with mainID = 1. A SQL join will return two records. What
I want is a single record, with both sub-records appended one after the
other. So I would end up with 'main table records' + 'sub table record
1' + 'sub table record 2'.
I assume that I will have to use VB script to do this, saving the
queries in an array or something like that, and then appending and
outputting from the code itself, not SQL per se. Are there any other
suggestions, or elegant solutions to this problem?
For those who are curious, I am doing this because I work with a
sociologist who needs the data in a flat format (there will be somewhere
around 3000 columns in the end - yuck).
Thanks,
Allie