mysql

作者: 今天比昨天努力 | 来源:发表于2020-04-23 14:13 被阅读0次

    1,分页

    select * from tableName LIMIT 10; //检索前10行数据,显示1-10条数据

    select * from tableName LIMIT 1,10; //检索从第2行开始,累加10条记录,共显示id为2-11

    所以开发的时候如果需要写到分页查询,需要传参数索引,一般来说是这样的,n是第几页,total是一页展示多少行数据

    select * from tableName LIMIT (n-1)*total,total;

    2 case when

    case sex 

    when 'boy'  then '男'

    when 'girl' then '女'

    case 

    when sex='boy' then '男'

    when sex='girl' then '女'

    3substr()函数

    数据库的记录从1开始,而不是从0开始。

    4 coalesce()函数

    依次参考各参数表达式,遇到非null值即停止并返回该值。如果所有的表达式都是空值,最终将返回一个空值。

    相关文章

      网友评论

        本文标题:mysql

        本文链接:https://www.haomeiwen.com/subject/pefaihtx.html