3

date processing function

  • If you need to use dates when comparing with the WHERE clause, use Date(). This can avoid errors caused by the same day, but the hour, minute and second are not 00:00:00, for example:

     SELECT cus_id, order_num FROM orders WHERE Date(order_date) = '2022-06-06';
  • If we want to retrieve all orders in June 2022, we need to take into account the number of days in different months. Here we recommend using the BETWEEN keyword:

     SELECT cus_id, order_num FROM orders WHERE Date(order_date) BETWEEN '2022-06-01' AND '2022-06-30';

Numerical processing functions

Commonly used are as follows:


Reference: Forta B. MySQL crash course[M]. Pearson Education India, 2006.

LiberHome
409 声望1.1k 粉丝

有问题 欢迎发邮件 📩 liberhome@163.com