Subject | select question - faster method |
---|---|
Author | Planles |
Post date | 2004-09-24T17:42:23Z |
Hello!
In first table I have master records. In second table there are details (one
or more records for each record from first table).
Table 1:
Field1, Field2
A1, C1
A2, C2
Table 2:
Field1, Field2
A1, D1
A1, D2
A2, E1
A2, E2
Joining this two tables on Field1 would give me this result:
A1, C1, D1
A1, C1, D2
A2, C2, E1
A2, C2, E2
What I realy want is result, where I get joined result, but just on first
record from second table.
Like this:
A1, C1, D1
A2, C2, E1
Searching for solution I found folowing:
select Table1.*, (select first 1 Table2.Field2 from Table2 where
Table1.Field1 = Table2.Field1)
from Table1
where (...search condition...)
It works, but I have a feeling, that this is not fastest solution.
Is there any other approach for this situation ?
Regards,
Primoz
In first table I have master records. In second table there are details (one
or more records for each record from first table).
Table 1:
Field1, Field2
A1, C1
A2, C2
Table 2:
Field1, Field2
A1, D1
A1, D2
A2, E1
A2, E2
Joining this two tables on Field1 would give me this result:
A1, C1, D1
A1, C1, D2
A2, C2, E1
A2, C2, E2
What I realy want is result, where I get joined result, but just on first
record from second table.
Like this:
A1, C1, D1
A2, C2, E1
Searching for solution I found folowing:
select Table1.*, (select first 1 Table2.Field2 from Table2 where
Table1.Field1 = Table2.Field1)
from Table1
where (...search condition...)
It works, but I have a feeling, that this is not fastest solution.
Is there any other approach for this situation ?
Regards,
Primoz