Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Strange mysql query problem

$
0
0
Hi, I was wondering if someone could help me with a strange mysql problem I am having.

I am seeing strange query behavior from one of my mysql servers. I ran the following two queries on three different servers all with the same data.

Code:

SELECT t1.Field1, t1.Field2, t1.Field3,
(SELECT t2.Field1
  FROM thetable AS t2
  WHERE Field2=t1.Field2 AND Field3=t1.Field3 AND t2.Field1>t1.Field1
  ORDER BY Field1
  LIMIT 1) AS MinimumResult
FROM thetable AS t1
WHERE t1.UserID=5;

SELECT t1.Field1, t1.Field2, t1.Field3,
(SELECT min(t2.Field1)
  FROM thetable AS t2
  WHERE Field2=t1.Field2 AND Field3=t1.Field3 AND t2.Field1>t1.Field1) AS MinimumResult
FROM thetable AS t1
WHERE t1.UserID=5;

On two of the three servers both queries return the same result. On the third, I get two different results for the MinimumResult field. The first query, returns a small number. The second query returns what I would expect and what both queries return on the other servers.

I am not sure how to respond to this? Is this a server config problem or expected behavior?

Thanks in advance for any help you can provide.

Viewing all articles
Browse latest Browse all 13329

Trending Articles