Im having an issue updating a table from a join. I did this kind of update many times but now its not working. Here is the original query:
select
surveydatakey
,a.Strata as [surveydata strata]
,SurveyPeriod
,DateOfSurvey
,StationLocation
,a.CardType
,a.timeperiod
,station_entrance
,Direction
,DayType
,EntranceType
,b.Strata as ActuaStrata
,StartDate
,currentdate
from surveydata a
inner join MAP_Entrance_Population b
on a.station_entrance_id = b.station_entrance_id
and a.timeperiod = b.tp
and a.strata <> b.strata
where mode = 'train'
and a.strata not in (1,14,15,21,22,23)
and dateofsurvey between startdate and currentdate
order by a.strata
Now this is the update query:
begin tran
update a
set a.strata = b.strata
from surveydata a
inner join MAP_Entrance_Population b
on a.station_entrance_id = b.station_entrance_id
and a.timeperiod = b.tp
and a.strata <> b.strata
where mode = 'train'
and a.strata not in (1,14,15,21,22,23)
and dateofsurvey between startdate and currentdate
The search query produces 218 results, the update says that it changes 218 results. In my search query I have the condition a.strata <> b.strata. My aim to to make these 2 equal each other. So I figured that after my update query, I should not get any results in my select query. But nothing actually changes. I still get the same 218 results after doing the update.
Any ideas?