mysql not equal to null filtration problems (simultaneous comparison is equal, greater than and less than)

Conditions in writing SQL statement is often used not equal '! =' Filter criteria, this time to pay attention to this condition will also field is null data as conditions are not equal and the data filtered out.

1, the original data and the table structure

CREATE TABLE `test01` (
  `ID` bigint(18) NOT NULL AUTO_INCREMENT,
  `NUM` bigint(18) DEFAULT NULL COMMENT 'NUM',
  `NAME` varchar(250) DEFAULT NULL COMMENT '名称',
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

data:

2, SQL and test results

Test Results

3, it can be found:

  • Is not equal to: filter will be empty (NB);
  • Equal: an exact match, no problem
  • Greater than or equal: not greater than empty, no problem
  • Less than or equal: Empty will be less than (pay attention).

Guess you like

Origin www.cnblogs.com/buwuliao/p/12033564.html