Be the princess of myself

发布新日志

  • 查询语句中包含日期

    2007-08-30 12:33:09

    select * from table t where to_char(t.列名,'yyyy-mm-dd') = '1900-01-01'

    将日期转换为字符型:

    select to_char(t.列名) from table t

  • 数据库及sql

    2006-12-20 10:54:05

    自从开发通过改了数据库的索引,大大提高了查询速度以后,第一次让我这个不懂数据库的人感到数据库的博大精深了。

    sql:

    长度函数:length

    例:查询student表中姓名的长度

    select length(stu.name) from student stu

    截取字符串函数:substr()

    例:查找学号前两位为12的学生

    select * from student stu where substr(stu,1,2)='12'

Open Toolbar