JOIN문이 이렇게 어려운지 몰랐습니다.
도와 주시면 감사하겠습니다.
두개의 테이블에서 countrycode에 대응하는 id번호를 찾아 아래의 id 공백에 삽입하려고 합니다.
ATABLE
id_nation countrycode countrycode2 countryname
1 AF AFG Afghanistan
2 AL ALB Albania
3 DZ DZA Algeria
4 AD AND Andorra
BTABLE
ipfrom ipto id_nation countrycode
33996344 33996351 GB
50331648 69956103 US
69956104 69956111 BM
삽질구문 :
1. Select * From ATABLE Left Join BTABLE On ATABLE.countrycode = 'BTABLE.countrycode';
2. UPDATE BTABLE SET id_nation = (SELECT id_nation FROM ATABLE WHERE ATABLE.countrycode = 'BTABLE.countrycode' LIMIT 1);
위의 2개 구문이 잘 안되는군요.
|