From: ben at thelocust dot org
Operating system: Linux and Windows
PHP version: 5.2.6
PHP Bug Type: MSSQL related
Bug description: NULL comparison when using "not in" not consistent with
Windows SQL
Description:
------------
When querying a MSSQL database table, and using the "not in" syntax, PHP's
mssql_query will also return rows with NULL in the field specified.
Reproduce code:
---------------
SQL Server 2000 or 2005
Table "test"
test_id (int) test_name (vchar) test_number (int)
1 Foo 1
2 Bar 2
3 <null> 3
4 Baz <null>
$sql = "select test_id from test where test_number not in (1,2)";
$res = mssql_query($sql);
while ($row = mssql_fetch_array($res)) {
?>
<?=$row['test_id'];?><br/>
<?
}
Expected result:
----------------
In PHP, either using FreeTDS on Linux or the MSSQL extension on Windows,
the above returns:
3
4
In ASP/VBScript or using Query Analyzer on Windows the following is
returned:
3
Windows' MSSQL driver apparently will not compare the "not in" values to a
NULL field. PHP, apparently, will.
This creates and inconsistency between the two platforms.
--
Edit bug report at http://bugs.php.net/?id=46575&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46575&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46575&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46575&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46575&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46575&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46575&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46575&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46575&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46575&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46575&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46575&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46575&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46575&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46575&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46575&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46575&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46575&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46575&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46575&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46575&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46575&r=mysqlcfg