可以经常看看 mysql的refman,写的很棒

sql基础操作

查看表结构

show create table
desc table
show full columns from test1;

like语句

1. where id > 1 and name != 'maotai' order by id desc
2. where name like '%sre%' # %任意长度 _任意单个字符,如 '_a_' //三位且中间字母是a的
3. where id not in (11,22,33)
4. where id between 3 and 8
5. 查询空值 6. 通过正则
select * from user where gender regexp '^(m|f)'; 7, limit offset SELECT * FROM t1 WHERE
(key1 < 'abc' AND (key1 LIKE 'abcde%' OR key1 LIKE '%b')) OR
(key1 < 'bar' AND nonkey = 4) OR
(key1 < 'uux' AND key1 > 'z');

mysql字段值长度为0和null的区别

常用函数

mysql> select max(age),min(age),sum(age),avg(age),count(age) from user;
+----------+----------+----------+----------+------------+
| max(age) | min(age) | sum(age) | avg(age) | count(age) |
+----------+----------+----------+----------+------------+
| 29 | 24 | 159 | 26.5000 | 6 |
+----------+----------+----------+----------+------------+
1 row in set (0.00 sec) concat 字符串拼接
left: 保留字符串的前两位
mysql> select left('age',2);
+---------------+
| left('age',2) |
+---------------+
| ag |
+---------------+
1 row in set (0.00 sec)

分组

mysql> select count(gender),gender,class from user group by class,gender;
+---------------+--------+-------+
| count(gender) | gender | class |
+---------------+--------+-------+
| 1 | female | 1 |
| 1 | male | 1 |
| 1 | female | 2 |
| 1 | male | 2 |
| 1 | female | 3 |
| 1 | male | 3 |
+---------------+--------+-------+

select if条件表达式

sql切割字符串

https://www.cnblogs.com/qiaoyihang/p/6270165.html

SELECT SPLIT_STR('a|bb|ccc|dd', '|', 3) as third;

+-------+
| third |
+-------+
| ccc |
+-------+
str = 'www.baidu.com';

SELECT substring_index('www.baidu.com','.', 1);    #www

SELECT substring_index('www.baidu.com','.', 2);    #www.baidu

SELECT substring_index('www.baidu.com','.', -1);   #com

SELECT substring_index('www.baidu.com','.', -2);   #baidu.com

SELECT substring_index(substring_index('www.baidu.com','.', -2), '.', 1);  #baidu
---------------------
作者:来了就走下去
来源:CSDN
原文:https://blog.csdn.net/u012009613/article/details/52770567
版权声明:本文为博主原创文章,转载请附上博文链接!

[sql]sql的select字符串切割的更多相关文章

  1. sql存储过程exec执行字符串select 的区别

    USE [GuangHong]GO/****** Object: StoredProcedure [dbo].[st_MES_SelInspctDetail] Script Date: 11/23/2 ...

  2. SQL Server中截取字符串常用函数

    SQL Server 中截取字符串常用的函数: .LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要截 ...

  3. sql server 查找包含字符串的对象

    sql server 查找包含字符串的对象 SELECT sm.object_id, OBJECT_NAME(sm.object_id) AS object_name, o.type, o.type_ ...

  4. 教您如何使用SQL中的SELECT LIKE like语句

    LIKE语句在SQL有着不可替代的重要作用,下文就将为您介绍SQL语句中SELECT LIKE like的详细用法,希望对您能有所帮助. LIKE语句的语法格式是:select * from 表名 w ...

  5. [置顶] VB6基本数据库应用(三):连接数据库与SQL语句的Select语句初步

    同系列的第三篇,上一篇在:http://blog.csdn.net/jiluoxingren/article/details/9455721 连接数据库与SQL语句的Select语句初步 ”前文再续, ...

  6. SQL Server 中截取字符串常用的函数

    SQL Server 中截取字符串常用的函数: 1.LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要 ...

  7. sql server中截取字符串的常用函数

    我们如果要在sql server中,使用截取字符串的方法要怎样使用呢? sql server提供了3个常用截取字符串方法,LEFT().RIGHT().SUBSTRING() /****** Sql ...

  8. Sql动态查询拼接字符串的优化

    Sql动态查询拼接字符串的优化 最原始的 直接写:string sql="select * from TestTables where 1=1";... 这样的代码效率很低的,这样 ...

  9. SQL Fundamentals: Basic SELECT statement基本的select语句(控制操作的现实列)(FROM-SELECT)

    SQL Fundamentals || Oracle SQL语言 Capabilities of the SELECT Statement(SELECT语句的功能) Data retrieval fr ...

随机推荐

  1. The best manual of how to use "The easiest Xdebug" addon for Firefox

    Installation notes 0. Install the best Firefox add-on for remote debugging The easiest Xdebug. I'm n ...

  2. Fluent动网格【11】:弹簧光顺

    动网格除了前面讲了很多的关于运动指定之外,另一个重要主题则为网格的更新. 在部件运动之后,不可避免的会造成网格形状的变化,如若不对网格加以控制,在持续运动的过程中,则可能造成网格极度变形.歪曲率过大, ...

  3. 【原创 深度学习与TensorFlow 动手实践系列 - 3】第三课:卷积神经网络 - 基础篇

    [原创 深度学习与TensorFlow 动手实践系列 - 3]第三课:卷积神经网络 - 基础篇 提纲: 1. 链式反向梯度传到 2. 卷积神经网络 - 卷积层 3. 卷积神经网络 - 功能层 4. 实 ...

  4. 看雪CTF第十四题

    from z3 import * dest=[] s = Solver() data = [, , , , , , , , , , , , , , , , , , , , , , , , , , , ...

  5. 微信开发时调用jssdk,在安卓设备中成功调用;在ios设备中返回错误消息:config fail,无其他具体错误消息,且接口权限显示获取ok,无法调用

    js代码如下: JavaScript code   ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...

  6. mongoDB用法整理

    1. mongoDB UI工具, Studio 3T,用Non_Commercial的版本就足够. 2. 查询某字段长度大于特定值的 db.test.find({ F_DAQDATA: { $type ...

  7. java maven 编译文件时 有些类型文件 不存在

    在pom.xml中添加如下: <build> <resources> <resource> <directory>src/main/resource&l ...

  8. java 中 ResourceBundle 使用 国际化使用

    java 中 ResourceBundle 使用 可以根据以下类进行获取国际化文件: package org.mybatis.generator.internal.util.messages; imp ...

  9. ftrace:跟踪你的内核函数! | Linux 中国

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/F8qG7f9YD02Pe/article/details/79161135 ftrace 是一个 L ...

  10. 【PostgreSQL】资料索引(来源:德哥)

    PostgreSQL 多应用场景实践 - 沙箱实验 https://github.com/digoal/blog/blob/master/201805/20180524_02.md 一.GIS < ...