Last night I was looking over one of my applications on my development
box, and realized that the results I was getting were rather different
from what I had expected. It was still working fine on my working
server. I copied over the current version of the tables to the 
dev box, and made sure that the scripts were identical, which they were,
but I was still getting different results.

Then I started to play around with the SQL, and discovered that even
with identical data and identical queries, I was getting different
results. I'm at a loss to explain this and would greatly appreciate
any help figuring out what's going on.

My working server is running MySQL 4.0.10, and the development server
is running 4.0.13, both on FreeBSD 4.8-STABLE. I have some configuration
differences but nothing that I think could affect this.

I have a database of wine, and a relevant part is that there is a table
"wine" holding info about what was purchased, and a table "deaccession_event"
holding info about wine that I have sold or drunk, with a field
"deac_quantity" having the number of wines drunk/sold on any particular
occasion.

I execute the following query:

SELECT wine.id, 
wine.orig_qty_purch - SUM(deaccession_event.deac_quantity) AS number_left
FROM wine 
LEFT JOIN deaccession_event ON wine.id = deaccession_event.wine_id
GROUP BY wine.id ORDER BY wine.id;

on my working server (4.0.10-gamma) I get:

+-----+-------------+
| id  | number_left |
+-----+-------------+
|   1 |           0 |
|   2 |           1 |
|   3 |           1 |
|   4 |           1 |

[...]

| 103 |           2 |
| 104 |           1 |
| 105 |           4 |
| 106 |           4 |
| 107 |           0 |
| 108 |           4 |
| 109 |           0 |
| 110 |           0 |
| 111 |           0 |
| 112 |           0 |
| 113 |           0 |
+-----+-------------+

and on my development server (4.0.13) I get:

+-----+-------------+
| id  | number_left |
+-----+-------------+
|   1 |           0 |
|   2 |        NULL |
|   3 |        NULL |
|   4 |        NULL |

[...]

| 103 |           2 |
| 104 |           1 |
| 105 |        NULL |
| 106 |        NULL |
| 107 |           0 |
| 108 |           4 |
| 109 |           0 |
| 110 |           0 |
| 111 |           0 |
| 112 |           0 |
| 113 |           0 |
+-----+-------------+

I'm sure that these are working on identical tables and that the queries
are identical. This is just a sample, and more complex queries end up
with more thoroughly erroneous results.

Any explanation for these results? Thanks in advance.

Jesse Sheidlower

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to