I am a bit confused. It looks pretty simple and I am sure, this has been resolved and published before. However, after searching for hours, I still haven’t found a solution for this little problem:
t1.ENTRY is the first part of the composite key
t1.COPY is the second part of the composite key
SELECT t1.ENTRY, t1.COPY, t1.TTYPE, t2.ENTRY FROM SymbolText t1
INNER JOIN Symboldata t2 ON t1.ENTRY =t2.LPNTR
WHERE t1.ENTRY = 'LS-85601366-E515-4B3D-BE10-4D8C01F0E08F'
This is what I get from the above query:
ENTRY COPY TTYPE ENTRY
1 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 1 18 CIM08-50-10
2 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 2 14 CIM08-50-10
3 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 3 15 CIM08-50-10
4 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 4 12 CIM08-50-10
5 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 5 528 CIM08-50-10
6 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 6 5 CIM08-50-10
7 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 7 527 CIM08-50-10
8 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 8 522 CIM08-50-10
9 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 9 534 CIM08-50-10
10 LS-85601366-E515-4B3D-BE10-4D8C01F0E08F 10 523 CIM08-50-10
I want to get the t2.ENTRY of all records with
t1.ENTRY = 'LS-85601366-E515-4B3D-BE10-4D8C01F0E08F' and
t1.TTYPE = '528' and
t1.TTYPE = '5'
What I am really looking for is something like this:
1 CIM08-50-10
But if I run the query like this:
SELECT t2.ENTRY FROM SymbolText t1
INNER JOIN Symboldata t2 ON t1.ENTRY =t2.LPNTR
WHERE t1.ENTRY = 'LS-85601366-E515-4B3D-BE10-4D8C01F0E08F' AND (t1.TTYPE = '5' AND t1.TTYPE = '528')
I won’t get any results as there is obviously not such record having both TTYPE = ‘5’ and TTYPE ‘528’. I need just one record back based on the the combination of both keys.
Any hints what I am missing?
Tommy Wehrli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.