When executing this query below it takes too long. And the result is too much records, more than possibly in the database. The query should return around 117.000 records. That is the amount of records enterred into the database during a period of half a year.
Why is this query multiplying, resulting in millions of records? If someone could give me the clu where I'm stuck, I'll be very happy.
/* Formatted on 2011/08/05 17:09 (Formatter Plus v4.8.7) */ SELECT t2.flag, t3.reg_number, t1.reportdate, t1.latitude, t1.longitude, t1.value2 course, ((t1.measspeed) * 3.6) / 1.852, t1.status alarms FROM traffic t1, details t2, registernumbers t3 WHERE t1.mobileno = t2.mobile AND t2.mobile = t3.mobileno AND UPPER (t2.flag) = UPPER ('BEL') AND t1.reportdate BETWEEN '1/jan/2011' AND '1/jul/2011' AND (latitude > 52 AND longitude > 2) AND latitude > 48 OR (latitude < 52 AND longitude > 2) OR (latitude > 52 AND longitude < 2)
ORDER BY reportdate DESC
/* Formatted on 2011/08/05 17:09 (Formatter Plus v4.8.7) */
SELECT t2.flag, t3.reg_number, t1.reportdate, t1.latitude, t1.longitude,
t1.value2 course, ((t1.measspeed) * 3.6) / 1.852, t1.status alarms
FROM traffic t1, details t2, registernumbers t3
WHERE t1.mobileno = t2.mobile
AND t2.mobile = t3.mobileno
AND UPPER (t2.flag) = UPPER ('BEL')
AND t1.reportdate BETWEEN '1/jan/2011' AND '1/jul/2011'
AND (latitude > 52 AND longitude > 2)
AND latitude > 48
OR (latitude < 52 AND longitude > 2)
OR (latitude > 52 AND longitude < 2)
ORDER BY reportdate DESC
Thanks in advance,
Maarten