note 29699 added to function.mysql-num-rows

From: Date: Fri, 21 Feb 2003 23:40:45 +0000
Subject: note 29699 added to function.mysql-num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-44331@lists.php.net to get a copy of this message
I may indeed be the only one ever to encounter this - however if you have a myisam table with one row, and you search with valid table and column name for a result where you might expect 0 rows, you will not get 0, you will get 1, which is the myisam optimised response when a table has 0 or one rows. Under "5.2.4 How MySQL Optimises WHERE Clauses" it reads: *Early detection of invalid constant expressions. MySQL quickly detects that some SELECT statements are impossible and returns no rows. and *All constant tables are read first, before any other tables in the query. A constant table is: 1) An empty table or a table with 1 row. 2) A table that is used with a WHERE clause on a UNIQUE index, or a PRIMARY KEY, where all index parts are used with constant expressions and the index parts are defined as NOT NULL. Hopefully this will keep someone from staying up all night with 1146 errors, unless I am completely mistaken in thinking I have this figured out. -- http://www.php.net/manual/en/function.mysql-num-rows.php http://master.php.net/manage/user-notes.php?action=edit+29699 http://master.php.net/manage/user-notes.php?action=delete+29699 http://master.php.net/manage/user-notes.php?action=reject+29699

« previous php.notes (#44331) next »