sample.db라는 데이터베이스를 만들었습니다.sqlite 명령을 사용하여 2 개의 테이블 조인
내가 3 열을 기반으로 두 테이블에 가입 할 -test와 TEST1 (데이터베이스 테이블)
2 개 CSV 파일 가져 왔습니다 - 타임 스탬프, 위도와 경도를. 당신이 볼 수 있듯이
시험은
o3,pm,co,so2,no2,longitude,latitude,timestamp
61,82,52,49,54,10.2466,56.2091,1410693900
66,83,51,44,51,10.2466,56.2091,1410694200
68,80,54,41,56,10.2466,56.2091,1410694500
66,79,53,42,59,10.2466,56.2091,1410694800
71,75,57,45,61,10.2466,56.2091,1410695100
75,75,60,50,61,10.2466,56.2091,1410695400
122,97,172,40,53,10.2507,56.2026,1412101200
TEST1
status,avgMeasuredTime,avgSpeed,extID,medianMeasuredTime,TIMESTAMP,vehicleCount,_id,REPORT_ID,Lat1,Long1,Lat2,Long2,Distance between 2 points,duration of measurements,ndt in kmh
OK,61,60,668,61,1410693900,4,20746723,158324,56.2091,10.2466,56.2258,10.1166,1030,52,71
OK,61,60,668,61,1410694200,1,20747172,158324,56.2091,10.2466,56.2258,10.1166,1030,52,71
OK,63,58,668,63,1410694500,3,20747545,158324,56.2091,10.2466,56.2258,10.1166,1030,52,71
OK,71,52,668,71,1410694800,6,20747994,158324,56.2091,10.2466,56.2258,10.1166,1030,52,71
OK,67,55,668,67,1410695100,5,20748443,158324,56.2317,10.1050,56.2091,10.2466,1030,52,71
OK,62,59,668,62,1410695400,6,20748892,158324,56.2317,10.1050,56.2091,10.2466,1030,52,71
OK,67,55,668,67,1412101200,13,20749341,158324,56.2317,10.1050,56.2026,10.2507,1030,52,71
예상 출력
ozone,particullate_matter,carbon_monoxide,sulfure_dioxide,nitrogen_dioxide,longitude,latitude,timestamp,avgMeasuredTime,avgSpeed,medianMeasuredTime,Distance between 2 points,duration of measurements,ndt in kmh
61,82,52,49,54,10.2466,56.2091,1410693900,61,60,61,1030,52,71
66,83,51,44,51,10.2466,56.2091,1410694200,61,60,61,1030,52,71
68,80,54,41,56,10.2466,56.2091,1410694500,63,58,63,1030,52,71
66,79,53,42,59,10.2466,56.2091,1410694800,71,52,71,1030,52,71
71,75,57,45,61,10.2466,56.2091,1410695100,67,55,67,1030,52,71
75,75,60,50,61,10.2466,56.2091,1410695400,62,59,62,1030,52,71
122,97,172,40,53,10.2507,56.2026,1412101200,67,55,67,1030,52,71
, 나는 타임 스탬프, 위도와 경도에 따라 가입하려는. table2 (test1)에는 두 개의 경도 값이 있습니다. 그래서 table2의 경도 값 중 하나와 일치하는 table1의 경도를 비교하고 싶습니다. 마찬가지로 위도. 내가
select *
from test
join test1
on test.timestamp=test1.TIMESTAMP and
test.longitude=test1.Long1 or
test.longitude=test1.Long2 and
test.latitude=test1.Lat1 or
test.latitude=test1.Lat2;
을 시도 무엇
또한 나는 새 테이블에 결과를 저장할.
저는 sqlite를 처음 사용합니다. 그래서 INNER JOIN
에 대한 :)
올바르게 태그를 지정하십시오. 너 뭐 해봤 니? 나는 당신이 시도하지 못한 것을 보여주는 SQL 문을 보지 못했다. –
select *에서 test join test1 on (test.latitude = test1.latitude 및 test.longitude = test1.longitude 및 test.timestamp = test1.timestamp) – JYoThI
주석에 답변을 넣지 마십시오. 특히 그들이 맞지 않을 때. –