This is the question about JDBC. I have next task. I'm iterating through rows from table A and for some current row I want to execute some query against table B in context of current row from开发者_如何学Python A. For example, if I have some query like
SELECT B.description FROM A LEFT JOIN B ON A.ID = B.refId
then I want to get all results where B.refId="current row from A".ID. Please, note that I cannot modify query for selecting results from B.
For example, let's table A like this:
ID name
1 nameA
2 nameB
and table B:
ID description refID
1 desc1 1
2 desc2 1
3 decs3 2
4 desc4 2
So if I for example on row from table A with ID 2 and perform my query then I want to get "desc3" and "desc4" only.
I suggest that this task can be solved with cursors but I'm familiar with it. Can anyone give me a hint?
Based on the question
SELECT B.description FROM
A
INNER JOIN
B ON A.ID = B.refId
WHERE
A.ID = 2
SELECT B.description FROM
B
WHERE
B.refid = 2
Otherwise, I don't think we understand the question...
What is your question? The query you gave means "all results where B.refId=current row from A.ID".
Can you just make your description.
A.*
Not sure if I understand the question though.
精彩评论