Hello All
I upgraded from MySQL 4.1 to 5.0. Under 4.1, I had the following query, which ran without a glitch:
As you may see above, I am retrieving records from two tables: parentTable, and childTable which are linked by parentTableId. These records are sorted by a date field (parentTable.date).
Under 4.1, this query runs beautifully, but under 5.0, the records are not sorted properly. What happens is that the records that match the crietria childTable.parentTableId = 0 are shown first, even though their date is the latest. The rest of the records display afterwards, sorted asc by date.
They look like this:
[tt]2007-01-01 [green](must be at the bottom)[/green]
2007-01-01 [green](must be at the bottom)[/green]
2006-08-20
2006-08-21
2006-08-22[/tt]
I was going crazy with this, so I started doing all sorts of tests. The results were outrageous!!! I discovered that the cause of the problem is the line in red, [red]parentTable.parentTableID IN (4973)[/red]. Incredibly enough, if instead of using parentTableId, I would use a dateField for the criteria, the records would sort properly. Worse yet, if I changed that line to
[red]parentTable.parentTableID IN (0, 4973)[/red], the records would also sort properly.
Can anybody tell me what on earth is going on?
I have Windows 2000, all up-to date.
Also, I have all the latest updates and drivers from MySQL.
Thanks.
_________________________________
I think, therefore I am. [Rene Descartes]
I upgraded from MySQL 4.1 to 5.0. Under 4.1, I had the following query, which ran without a glitch:
Code:
select parentTable.dateField, childTable.number from parentTable
inner join childTable on parentTable.parentTableId = childTable.parentTableId
where (
childTable.parentTableId = 0
AND
childTable.number<=30
)
OR
(
childTable.number = 1
AND
(
childTable.parentTableId IN (4973)
)
OR
(
[red][b]parentTable.parentTableID IN (4973)[/b][/red]
AND childTable.someField IN (1,2,3,4,5)
)
)
order by parentTable.dateField
Under 4.1, this query runs beautifully, but under 5.0, the records are not sorted properly. What happens is that the records that match the crietria childTable.parentTableId = 0 are shown first, even though their date is the latest. The rest of the records display afterwards, sorted asc by date.
They look like this:
[tt]2007-01-01 [green](must be at the bottom)[/green]
2007-01-01 [green](must be at the bottom)[/green]
2006-08-20
2006-08-21
2006-08-22[/tt]
I was going crazy with this, so I started doing all sorts of tests. The results were outrageous!!! I discovered that the cause of the problem is the line in red, [red]parentTable.parentTableID IN (4973)[/red]. Incredibly enough, if instead of using parentTableId, I would use a dateField for the criteria, the records would sort properly. Worse yet, if I changed that line to
[red]parentTable.parentTableID IN (0, 4973)[/red], the records would also sort properly.
Can anybody tell me what on earth is going on?
I have Windows 2000, all up-to date.
Also, I have all the latest updates and drivers from MySQL.
Thanks.
_________________________________
I think, therefore I am. [Rene Descartes]