SQL Server - Qry Error ? - Asked By Jahir on 24-Feb-12 06:03 AM

what is error in this ?

adap = new SqlDataAdapter("select tbl_citymaster.cityid,tbl_regionmaster.regionname,tbl_statemaster.statename,tbl_citymaster.cityname from tbl_citymaster inner join tbl_regionmaster.id=tbl_citymaster.regionid and tbl_statemaster.name=tbl_citymaster.stateid", con);

Suchit shah replied to Jahir on 24-Feb-12 06:12 AM
what error r u getting ?
Jahir replied to Suchit shah on 24-Feb-12 06:38 AM
syntax error near=
Suchit shah replied to Jahir on 24-Feb-12 06:46 AM
Because you right the Inner join synxtax wrongly you have to right it like below

select table1.col1, table2.col2,table3.col1 from table 1
INNER JOIN table2 ON table1.ID = table2.ID
INNER JOIN table3 ON table3.ID = table1.ID

this is the correct way to do this.


select tbl_citymaster.cityid,tbl_regionmaster.regionname,tbl_statemaster.statename,tbl_citymaster.cityname
from tbl_citymaster inner join 
tbl_regionmaster ON tbl_regionmaster.id=tbl_citymaster.regionid
INNER JOIN tbl_statemaster ON  tbl_statemaster.name=tbl_citymaster.stateid



Above query is the correct version of your query which you posted here