0

I have a view named as This_View in the form:

Author  CoAuthor
----------------
677     901706
677     838459
677     901706
677     1695352
677     901706
1359    1695352
...  
...  

I have to select Name from another table against column i.e. Author and CoAuthor where value of Name for both Author and CoAuthor exist in the same column of Other_Table.

I have tried this:

SELECT name as Author, name as CoAuthor
FROM Other_Table AA
JOIN This_View YA ON YA.Author = AA.aid AND YA.CoAuthor = AA.aid
ORDER BY Author  

but not succeeded.

1 Answer 1

1

you have to make different JOIN for Author and Coauthor

SELECT AA.name as Author, BB.name as CoAuthor
FROM This_View YA 
JOIN Other_Table AA ON YA.Author = AA.aid
JOIN Other_Table BB ON YA.CoAuthor = BB.aid
ORDER BY AA.name 
Sign up to request clarification or add additional context in comments.

2 Comments

@Taufel Glad it helps you :)
Hmmm...I was aware of JOIN two or more tables but not aware of JOINing same table twice differently...anyhow a new curry to my menu :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.