select A.GEO_COORDINATE_RID , B.GEO_COORDINATE_RID
from FAC_FACILITY as A
right join SYS_GEO_COORDINATE as B
on A.CREATED_DATE= B.CREATED_DATE
where B.CREATED_BY = 'EPDMIG'
上面的select语句给出了340个结果,但是当我尝试在更新语句(下面)中使用时,它给出了0个结果
update A
set A. GEO_COORDINATE_RID = B.GEO_COORDINATE_RID
from FAC_FACILITY as A
right join SYS_GEO_COORDINATE as B
on A.CREATED_DATE= B.CREATED_DATE
where B.CREATED_BY = 'EPDMIG'
GEO_COORDIANTE _RID来自sys_GEO_COORDIANTE,是FAC_FACILITY表上的FK
更新声明中是否有任何遗漏?
答案 0 :(得分:0)
你有一个正确的JOIN,这意味着没有匹配A的行。有多少A.GEO_COORDINATE_RID为空?他们都是?如果你只是一个JOIN,那么任何行都会回来吗?
第二项,如果CREATED_DATE是DateTime,那么它们必须匹配到毫秒。不知道你在做什么,但如果你只关心这一天,你可以在下面加入。但话说回来,通常不会加入create_date。你应该加入GEO_COORDINATE_RID吗?
select A.GEO_COORDINATE_RID , B.GEO_COORDINATE_RID
from FAC_FACILITY as A
join SYS_GEO_COORDINATE as B
on CAST(A.CREATED_DATE AS DATE) = CAST(B.CREATED_DATE AS DATE)
where B.CREATED_BY = 'EPDMIG'