Home > DeveloperSection > Forums > Column 'Site_name' - ambiguous problem
Ankit Singh

Total Post:341

Posted on    September-30-2014 1:05 AM

 ASP.Net ASP.Net  MSSQL Server 

 3 Reply(s)
 985  View(s)
Rate this:

I have inner join two tables and display. I tried the given below code. But it generate on error "Ambiguous Column site_name' "


SELECT site_name, Mains_Run_Hrs, DG_Run_Auto_Mode, Battery_Run_Hrs,Solar_Run_hrs

FROM tbl_runtime_report INNER JOIN tbl_site_details

ON tbl_runtime_report.Site_ID=tbl_site_details.site_id


Chintoo Semi

Total Post:135

Posted on    September-30-2014 1:07 AM

Hi ankit,

If site_name resides in both tables, you need to specify which version you are querying i.e.


WHERE tbl_runtime_report.site_name = @site_name

Alternatively, you could use an alias


SELECT rt.site_name, ...

FROM tbl_runtime_report rt ...

WHERE rt.site_name = @site_name

Pravesh Singh

Total Post:412

Posted on    September-30-2014 1:11 AM

SELECT  Report.ColumnName,Details.ColumnName

FROM tbl_runtime_report Report

     INNER JOIN tbl_site_details  Details ON Report.Site_ID=Details .site_id

WHERE Report.site_name=@site_nam

Ankit Singh

Total Post:341

Posted on    September-30-2014 1:15 AM

select top (1) Dg_energy_daily, Load_energy_daily, mains_energy_daily,solar_energy_daily 

From tbl_energy_report

inner join tbl_site_details

ON tbl_energy_report.Site_ID=tbl_site_details.site_id

where tbl_site_details.site_name=@site_name order by sl_no desc

Don't want to miss updates? Please click the below button!

Follow MindStick