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.
When you use GROUP BY
MySql returns only one row per group, You have rows with similar tmc-time and MySql is returning only one row for all such rows that's the reason for decrease in row number.