我有3個表,其中2個表包含200 000條記錄,另一個表包含1 800 000條記錄。我使用2個限制條件合併這3個表格,即OCN and TIMESTAMP(month,year)
。前兩個表的月份和月份的列爲Monthx(包括月份,日期和年份)。和其他表作爲每個月和每年的單獨列。我把查詢作爲,包含1700萬條記錄的合併表
mysql--> insert into trail
select * from A,B,C
where A.OCN=B.OCN
and B.OCN=C.OCN
and C.OCN=A.OCN
and date_format(A.Monthx,'%b')=date_format(B.Monthx,'%b')
and date_format(A.Monthx,'%b')=C.IMonth
and date_format(B.Monthx,'%b')=C.month
and year(A.Monthx)=year(B.Monthx)
and year(B.Monthx)=C.Iyear
and year(A.Monthx)=C.Iyear
我給這個查詢4天它仍然running.could妳告訴我這個查詢是否是正確的還是錯誤的,並提供我一個準確的查詢。(我給了前達'%b'
,因爲我的C表有一個有JAN,MAR格式的月份。
請不要使用隱含的'where'加入,將它埋在1989年,它屬於哪裏。 (a.ocn = b.ocn和date_format(A.Monthx,'%b')= date_format(B.Monthx,'%b')....'使用顯式連接代替' – Johan