Pit road - Database SQL statement

Encountered when writing sql statement pit

When the field's data type is int integer, where the conditions of this type of query query field for the character sql character will automatically be converted to an integer processing

such as

select * from b2c where id = '6sdf832dsdfs';

Statement is actually running

select * from b2c where id = 6;

Is avoided to avoid, if not avoid processing method can refer to the following:

select * from b2c wehre CAST(id as CHAR) = '6wefw2dsd';

select * from b2c where CONVERT(id, CHAE) = '6wefw2dsd';

These two types of function parameters:

  Binary, binary prefix with the same effect: BINARY    
  character, parameters can be: CHAR
  Date: DATE     
  Time: TIME     
  DateTime: DATETIME     
  float: DECIMAL      
  integer: SIGNED     
  unsigned integer: UNSIGNED

 

Guess you like

Origin www.cnblogs.com/heiue/p/11325460.html