I have two tables which have roughly the same data but we could not mix them together due to the nature of the data input and presentation and to keep the table size small.
We run the followign script
SELECT * FROM (
SELECT dataString,dataInsertDateTime FROM tblMainData
WHERE deviceSerial='A111' AND mainDateTime BETWEEN '2012-06-20' AND '2012-07-07'
union
SELECT dataString,dataInsertDateTime FROM tblSecondData
WHERE deviceSerial='A111' AND mainDateTime BETWEEN '2012-06-20' AND '2012-07-07')
as table1
- The script runs quite slow
- I want to mix the data from both tables
- I want it ordered by mainDateTime
Thank you
ORDER BY
in your query? Are there rows that are identical (one intblMainData
and the other intblSecondData
) and you want them to appear once?