Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am trying to join 3 table here is my code bt its showing error continously can any 1 recogonize my error

SQL
SELECT        classify11.workclass, classify11.fnlwgt, classify11.Age, classify12.maritalstatus, classify13.education, classify12.workclass AS Expr1, 
                         classify13.workclass AS Expr2
FROM            classify11 INNER JOIN classify12 on classify11.workclass= classify12.workclass
                         classify12 INNER JOIN classify13 on classify12.workclass = classify13.workclass;


the error is

Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'classify12'.


Thank You..
Posted

It is working: you have a syntax error.

SQL
SELECT 
classify11.workclass, classify11.fnlwgt, classify11.Age, classify12.maritalstatus, classify13.education, classify12.workclass AS Expr1, classify13.workclass AS Expr2
FROM classify11 
INNER JOIN classify12 on classify11.workclass=classify12.workclass
INNER JOIN classify13 on classify12.workclass = classify13.workclass;
 
Share this answer
 
Comments
usha C 16-Jul-13 8:03am    
Ya nw working wats the mistake i had done here sir...
Zoltán Zörgő 16-Jul-13 8:10am    
Your error was here:
FROM classify11 INNER JOIN classify12 on classify11.workclass= classify12.workclass
classify12 INNER JOIN classify13 on classify12.workclass = classify13.workclass;

You don't have to repeat the second table name, since you are chaining the joins: ((A x B) x C)
usha C 16-Jul-13 8:52am    
k k fyn thnk u...
Zoltán Zörgő 16-Jul-13 9:03am    
Sorry, but I don't understand "k k fyn thnk u...".. it seems Klingon to me not English... :)
You encountered this error because there is a Table name before Inner join and after
on condition.. Try this one... you can use table aliases....
SQL
SELECT c11.workclass, c11.fnlwgt, c11.Age, c12.maritalstatus,
c13.education, c12.workclass AS Expr1,c13.workclass AS Expr2
FROM classify11 c11
INNER JOIN classify12 c12 on c11.workclass= c12.workclass
INNER JOIN classify13 c13 on c12.workclass = c13.workclass
 
Share this answer
 
Comments
usha C 16-Jul-13 8:07am    
Ya its working thnk u..
Raja Sekhar S 16-Jul-13 8:07am    
You are Welcome....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900