• 数据库操作(四)、标量函数


    标量函数

      1、大写:upper();

            select upper(列名) from 表名;

      2、小写:lower();

            select lower(列名) from 表名;

      3、截取字符串:substring();

            select substring(列名,从谁开始,截取几个) from 表名;

      4、指定字符串的起始位置:charindex();

            select charindex('值1',列名,从几开始) from 表名;

                     '值1':找谁     列名:从哪找

            select charindex(列名1,列名2,截取几个) from 表名;

                     两列相比

          也可写在where条件中使其语句有意义:select * from 表名 where charindex(列名1,列名2,截取几个)>0;

      5、打印长度,去首尾空格len();

            select len(列名) from 表名;

      6、去掉左边空格打印值,ltrim();

            select ltrim(列名) from 表名;

         去掉右边空格打印值,rtrim();

             select rtrim(列名) from 表名;

      7、从列最左边开始截取值:left();

               select left(列名,截取几个) from 表名;

        从列的最右边开始截取值:right();  

            select right(列名,截取几个) from 表名;

      8、取空值:isnull(); 

            select isnull(列名,'xx') from 表名;

           注:若xx为空,则打印空

           

            

  • 相关阅读:
    Bootstrap
    Asp.Net母版页的相关知识
    连接Access数据库的连接字符串
    登录界面更换验证码图片
    .NET中string与StringBuilder在字符串拼接功能上的比较
    Asp.Net(C#)使用oleDbConnection 连接Excel
    非常规方法实现添加合并列
    ASP.Net页面间变量值传递的方法
    eclipse配置class注释模板
    spring中web.xml指定配置文件
  • 原文地址:https://www.cnblogs.com/Yida-Tingting/p/4434935.html
Copyright © 2020-2023  润新知