3
나는 load local infile
명령을 사용하여 mysql db에로드하는 CSV 파일을 가지고 있습니다.mysql은로드 infile의 다른 테이블에서 선택하십시오
csv에는 5 가지 값의 열거 형에서 수집 된 필드 집합이 있으므로이 값을 기반으로 쿼리해야합니다. 쿼리 (최대 6 백만 행) 가능성이 문자열 값 대신 ID를 삽입하려면 참조 테이블을 선택하려면 노력하고 있어요. http://dev.mysql.com/doc/refman/5.1/en/load-data.html 하위 쿼리에 따르면
load data local infile 'test_file.csv'
into table matching
fields terminated by ','
enclosed by '"'
(... @match, ...)
set
...
match = select id from matchRefData where name = @match,
...;
는 설정 작업의 오른쪽에서 사용할 수 있지만 매번 실패 할 것 같다
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'select id from matchRefData where name = @match,...'
버전 정보 :
Server 버전 : 5.5.25 소스 분포
+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| innodb_version | 1.1.8 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.25 |
| version_comment | Source distribution |
| version_compile_machine | i386 |
| version_compile_os | osx10.7 |
+-------------------------+---------------------+
매력처럼 작동했습니다! 고맙습니다 :) – Mann