Here is my current sql query
SELECT
w.city, t.tmc, t.date, t.time, w.event,
ROUND(AVG(w.Pave), 0) surface_temperature,
ROUND(AVG(w.Air), 0) air_temperature,
ROUND(AVG(a.material_rate),0) material_rate,
w.intensity, t.avg
FROM winter2010.traffictest t
LEFT OUTER JOIN winter2010.application a ON a.DATE = t.DATE AND a.tmc = t.tmc AND a.tmc = t.tmc AND Left(a.time,2) = Left(t.time, 2)
LEFT OUTER JOIN winter2010.weather w ON t.DATE = w.DATE AND t.tmc = w.tmc AND Left(t.time, 2) = Left(w.time, 2)
GROUP BY tmc, t.time
INTO OUTFILE 'c:/sass2.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES
TERMINATED BY '\n';
I'm creating this csv file from the following sql statement and it works great except for one thing, its only taking 1/2 the rows!
There are a total of 2661 rows in traffictest And when I outfile the data into the csv its only putting 1331.
I've changed the size of traffictest and this holds true except when I had only 3 rows it actually pulled all three rows.
Any help figuring this out would be much appreciated.
当您使用GROUP BY
MySql每个组仅返回一行时,您的行具有类似的tmc-time,而MySql对于所有此类行仅返回一行,这就是行数减少的原因。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.