Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 5 tables:

  • A (a_id, a1, a2)
  • B (b_id, b1, b2, a_id)
  • C (c_id, c1, c2, b_id)
  • D (d_id, d1, b_id)
  • E (e_id, e1, e2, d_id)

Here is some information

  • table b have a_id match with table a (a_id).
  • table c have b_id match with table b (b_id).
  • table d have b_id match with table b (b_id).
  • table e have d_id match with table d (d_id).

Now, I want to use inner join to get data from those tables. please help me!

share|improve this question

closed as unclear what you're asking by ypercubeᵀᴹ, David Spillett, Marian, Nick Chammas, StanleyJohns Jul 4 '13 at 17:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Do you really name your tables with 1-character names A, B, C, D, E? – ypercubeᵀᴹ Jul 4 '13 at 15:58
To get what data from those tables? There are practically infinite ways you could join them together to get different result sets out... – David Spillett Jul 4 '13 at 16:04
@ypercube: it similar to my tables – rocky Jul 4 '13 at 16:07
@David Spillett: i used where or join to query, it's ok. Now i want to use inner join to query them – rocky Jul 4 '13 at 16:09
That is still very very vague. What sort of result do you want out of the query? What query were you using before that worked? Why do you need to change to an inner join - what are you trying to accomplish with the change? What have you tried? What was the result (no data, duplicated data, wrong data, ...)? – David Spillett Jul 4 '13 at 16:31
up vote 4 down vote accepted

Is this what you are looking for. Inner join will fetch data only when identical data matched in all tables.

Select A.*,B.*,C.*,D.*,E.*
from A
inner join B on A.a_id = B. a_id
inner join C on B.b_id = C.b_id
inner join D on B.b_id = D.b_id
inner join E on D.d_id = E.d_id
share|improve this answer
thanks for your help – rocky Jul 4 '13 at 16:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.