mysql datetime comparison

前端 未结 3 714
一向
一向 2020-12-23 16:10

For example the following query works fine:

SELECT * 
  FROM quotes 
 WHERE expires_at <= \'2010-10-15 10:00:00\';

But this is obviously

3条回答
  •  被撕碎了的回忆
    2020-12-23 16:36

    But this is obviously performing a 'string' comparison

    No. The string will be automatically cast into a DATETIME value.

    See 11.2. Type Conversion in Expression Evaluation.

    When an operator is used with operands of different types, type conversion occurs to make the operands compatible. Some conversions occur implicitly. For example, MySQL automatically converts numbers to strings as necessary, and vice versa.

提交回复
热议问题