Hi all,

I am facing a rather curious problem with a SELECT clause. The table I'm querying has this definition:

Code:
CREATE TABLE `rx_tbl` (
`rx_id` int(11) NOT NULL auto_increment,
`fecha` datetime default NULL,
`ip` varchar(15) NOT NULL default '0',
`puerto` int(11) NOT NULL default '0',
`nserie` int(11) NOT NULL default '0',
`tt` tinyint(3) unsigned NOT NULL default '255',
`procesado` tinyint(1) unsigned NOT NULL default '0',
`datos` text,
PRIMARY KEY (`rx_id`),
KEY `procesado_ASC` (`procesado`),
)

Several apps are accessing the table. One insets records (leaving the default value 0 for 'procesado') with several values for the 'tt' field. The other apps are just making SELECTs for different values of 'tt', processing the data and updating the table making 'procesado'=1.

Code:
SELECT * FROM rx_tbl WHERE procesado = 0 AND tt <> 26 AND tt <> 27 AND tt <> 9
Code:
SELECT * FROM rx_tbl WHERE procesado = 0 AND (tt = 26 OR tt = 27)

Everything works like a charm until, at random intervals, the SELECT clauses return an abnormal number of rows (arround 500000 for the first SELECT, and 30000 for the second)... this number of rows is the same that would be returned if the condition "procesado=0" was not used.

The SELECT and UPDATE sentences are hard coded, so no mistake can be made depending on the value of a variable. The MySQL server is v4.0.20, the one that comes with debian unstable.

After several days, I have no clue on how to solve this. Any help will be appreciated.