使用数据处理函数

  1. select vend_name, Upper(vend_name) as vend_name_upcase from vendors order by vend_name

Left()
Lenght()
Locate()
Lower()
LTrim()
Right()
RTrim()
Trim()
Soundex()

  1. select cust_name, cust_contact from customers where cust_contact = 'Y. Lie'

  2. 发音相似的列: select cust_name, cust_contact from customers where Soundex(cust_contact) = Soundex ( 'Y. Lie');

日期函数

  1. select cust_id, order_num from orders where order_data = '2007-09-01'
    order_date的数据类型是datetime, 计入数据库中存储的是order_data : '2007-09-01 39: 34:12'`,该如何匹配呢?

  2. select cust_id, order_num from orders where Date(order_data) = '2007-09-01'

  3. 检索2005年9月的所有订单
    select cust_id, order_num from orders where Date(order_data) between '2005-09-01' and '2005-09-30'; select cust_id, order_num from orders where Year(order_data) = 2005 and Month(order_date) = 9;

posted @ 2024-05-28 17:22  肥梁  阅读(11)  评论(0)    收藏  举报