D
djc
table1:
MainID
Field1
Field2
table2:
MainID
Field3
Field4
Lets say I join them on MainID... my result set will only contain the fields
from table1 but my criteria will be checking values in table2. From my query
I can join the tables and check my criteria in the WHERE clause (say, on
Field3) to return a result 'close' to what I need. That result set can have
duplicate MainID's because table2's MainID is not the primary key alone.
table2's primary key is a combo of MainID and Field3. So there are several
records in table2 that have the same MainID. So what I need is only one
occurence of each record from table1 based on MainID returned from this
query...
this should make it more clear. Here is a sample result of my current inner
join query with WHERE clause testing field3 in table2.
table1.MainID, table1.Field1, table1.Field2, table2.Field3
100, some data, some more data, matching data
100, some data, some more data, different matching data that also met
criteria
100, some data, some more data, yet another different match for the criteria
my final result set for this match needs to have only one occurence of the
table1 information like this:
100, some data, some more data
anyone? I rushed this so I apologize for what is probably a very unclear
post. If I don't figure it out or get some input I'll repost with better
attention and detail Actually, as I just reread this I think I know the
answer but I will post to see what others might say anyway... I should be
able to use the DISTINCT keyword here right? Originally I thought I couldn't
since it applies to all fields but since I can use the criteria fields in
the WHERE clause without them being in the SELECT part of the statement then
DISTINCT should work.. I'll go try..
any input is appreciated. Thanks.
MainID
Field1
Field2
table2:
MainID
Field3
Field4
Lets say I join them on MainID... my result set will only contain the fields
from table1 but my criteria will be checking values in table2. From my query
I can join the tables and check my criteria in the WHERE clause (say, on
Field3) to return a result 'close' to what I need. That result set can have
duplicate MainID's because table2's MainID is not the primary key alone.
table2's primary key is a combo of MainID and Field3. So there are several
records in table2 that have the same MainID. So what I need is only one
occurence of each record from table1 based on MainID returned from this
query...
this should make it more clear. Here is a sample result of my current inner
join query with WHERE clause testing field3 in table2.
table1.MainID, table1.Field1, table1.Field2, table2.Field3
100, some data, some more data, matching data
100, some data, some more data, different matching data that also met
criteria
100, some data, some more data, yet another different match for the criteria
my final result set for this match needs to have only one occurence of the
table1 information like this:
100, some data, some more data
anyone? I rushed this so I apologize for what is probably a very unclear
post. If I don't figure it out or get some input I'll repost with better
attention and detail Actually, as I just reread this I think I know the
answer but I will post to see what others might say anyway... I should be
able to use the DISTINCT keyword here right? Originally I thought I couldn't
since it applies to all fields but since I can use the criteria fields in
the WHERE clause without them being in the SELECT part of the statement then
DISTINCT should work.. I'll go try..
any input is appreciated. Thanks.