SQL语句函数总结

SQL 函数 FIND_IN_SET(c1,cs)的用法

C1    希望搜索的数据为一个数据

CS    是一个数据的集合

总结:返回c1在集合cs中的全部记录信息


借鉴于:xiaokangmiclong

SQL 函数 cast的用法

Cast(字段名 as 转换的类型 ),其中类型可以为:

CHAR[(N)] 字符型 
DATE  日期型
DATETIME  日期和时间型
DECIMAL  float型
SIGNED  int
TIME  时间型

例如表table1

date

2015-11-03 15:31:26

select cast(date as signed) as date from  table1;

结果如下:

date

20151103153126

select cast(date as char) as date from  table1;

结果如下:

date

2015-11-03 15:31:26

select cast(date as datetime) as date from  table1;

结果如下:

date

2015-11-03 15:31:26

select cast(date as date) as date from  table1;

结果如下:

date

2015-11-03

select cast(date as time) as date from  table1;

结果如下:

date

15:31:26

这里date对应日期,time对应时间



转自: http://blog.sina.com.cn/s/blog_6094cbf30100frz0.html 

SQL 函数 instr的用法

INSTR(C1,C2,I,J) 在一个字符串中搜索指定的字符,返回发现指定的字符的位置;
C1    被搜索的字符串
C2    希望搜索的字符串
I     搜索的开始位置,默认为1
J     出现的位置,默认为1
SQL> select instr("abcde",'b');

结果是2,即在字符串“abcde”里面,字符串“b”出现在第2个位置。如果没有找到,则返回0;不可能返回负数



简单一句就是:instr函数返回字符串str中子字符串substr第一次出现的位置,在sql中第一字符的位置是1,如果 str不含substr返回0。

猜你喜欢

转载自blog.csdn.net/xubensheng1502sdut/article/details/79071062