我在从联接更新表时遇到问题。我做了很多次这种更新,但现在它不起作用。这是原始查询:
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
现在这是更新查询:
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
搜索查询产生 218 个结果,更新说它更改了 218 个结果。在我的搜索查询中,我有条件 a.strata <> b.strata。我的目标是使这两个彼此相等。所以我认为在我的更新查询之后,我不应该在我的选择查询中得到任何结果。但实际上没有任何改变。更新后我仍然得到相同的 218 结果。
有任何想法吗?