select vend_name ,upper(vend_name) as vend_name_upcase from vendors order by vend_name;
upper函数是将字符全部大写
select vend_name ,lower(vend_name) as vend_name_upcase from vendors order by vend_name;
lower()函数是将字符全部小写
select cust_name,cust_contact from customers where soundex(cust_contact) = soundex('y lie');
soundex()函数是找出和所给字符串读音很像的匹配行,注意 sql语句格式
bselect cust_id,order_num from orders where order_date = '2005-09-01';
这个语句并不安全,如果order_num中包含时间,这个语句搜索失败
select cust_id,order_num from orders where date(order_date) between '2005-09-01' and '2005-09-30';
date()函数只提取日期,多余的不管,如果想筛选出2005年9月份所有订单用接下来的语句
select cust_id,order_num from orders where year(order_date) =2005 and month(order_date)=9;
year()函数和month()函数与date()函数作用相同,仅提取对应时期
网友评论