0
select t.name 
from (pratip_Person natural join pratip_M_Director) as t;

What is the syntax error in this query?

3
  • I googled a lot but could not come to a satisfiable solution . Commented Feb 3, 2015 at 17:10
  • Where's the join condition? Parentheses aren't needed. You can alias specific tables not the join statement. Commented Feb 3, 2015 at 17:27
  • In my opinion natural join should be avoided because it is susceptible to side effects. Personally I would always use the more explicit join on Commented Feb 3, 2015 at 17:28

1 Answer 1

1

The brackets around (pratip_Person natural join pratip_M_Director) are your problem!

Try

select t.name from pratip_Person natural join pratip_M_Director as t;

(unless the Q at the start is really part of your query!)

Sign up to request clarification or add additional context in comments.

4 Comments

why is that a problem ? If we dont put he brackets then how can we identify whether t represents pratip_M_Director or the natural join ?
I am not really sure how t could represent the natural join as opposed to either the pratip_M_Director table or the entire select statement... but the brackets being where they are now is causing the syntax error.
@jaig You alias tables, not join operations. A field can come either from Person or Director. If you have a column named Name in both, you need to specify whether you want the Person's or the Director's Name. Are you confusing the join with a subquery?
The closing parenthesis is in the wrong place. Also, the parentheses are completely redundant. But the parentheses in and of themselves aren't 'the problem'; just their positioning.

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.