If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SELECT clause ignoring one WHERE condition

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-20-04, 12:32
ediaz ediaz is offline
Registered User
 
Join Date: Jul 2004
Posts: 1
SELECT clause ignoring one WHERE condition

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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On