2011-03-14 3 views
0

나는이도움말

select * from Properties 
join PPHL on PPHL.postcode = Properties.postcode 
and PPHL.name = Properties.propertyname 
and PPHL.id <> Properties.propertycode 
where Properties.clientid = 1 

나는 PPHL 테이블에서 id가이 쿼리의 결과에서 모든 속성을 업데이트 할이 사람이 내가 필요 올바른 SQL을 알고 않습니다 다음 쿼리 이 작업을 수행? 나는 이것을 mysql 5에서 돌리고있다.

답변

2

set 절은 테이블 조인 후에 간다. 구문 도움말은 MySQL documentation for UPDATE을 참조하십시오.

UPDATE Properties 
    JOIN PPHL ON PPHL.postcode = Properties.postcode 
      and PPHL.name = Properties.propertyname 
      and PPHL.id <> Properties.propertycode 

SET Properties.propertycode = PPNL.id 
WHERE Properties.clientid = 1