随笔分类 - MySql数据库及服务器
摘要:mysql> SHOW TABLES; //数据库有哪些表 +----------------+ | Tables_in_test | +----------------+ | animals | | event | | pet | | shop | | t1 | +---------------...
阅读全文
摘要:SELECT * FROM 表名 where uid='xxx' and time is not null
阅读全文
摘要:“_”:匹配任何单个字符“%”:匹配任意数目字符(包括零字符)“[abc]”:匹配“a”、“b”或“c”。为了命名字符的范围,使用一个“-”。“[a-z]”:匹配任何字母“[0-9]”:匹配任何数字“ * ”:匹配零个或多个在它前面的字符。例如,“x*”匹配任何数量的“x”字符,“[0-9]*”匹配
阅读全文
摘要:找出包含正好5个字符的名字,使用“^”和“$”匹配名字的开始和结尾,和5个“.”实例在两者之间:mysql> SELECT * FROM pet WHERE name REGEXP '^.....$'
阅读全文
摘要:要想找出正好包含5个字符的名字使用“_”模式字符:mysql> SELECT * FROM pet WHERE name LIKE '_____'“_”:匹配任何单个字符“%”:匹配任意数目字符(包括零字符)
阅读全文
摘要:要想找出以“y”结尾的名字:mysql> SELECT * FROM pet WHERE name LIKE '%y'“_”:匹配任何单个字符“%”:匹配任意数目字符(包括零字符)
阅读全文
摘要:要想找出包含“w”的名字:mysql> SELECT * FROM pet WHERE name LIKE '%w%'“_”:匹配任何单个字符“%”:匹配任意数目字符(包括零字符)
阅读全文
摘要:找出以“b”开头的名字:select * from pet where name like 'b%' “_”:匹配任何单个字符“%”:匹配任意数目字符(包括零字符)
阅读全文
摘要:将日期时间2016-05-13 16:07:50转化为字符串20160513 date_format select phone, date_format(time, '%Y%m%d%H%i%s') from user where phone='xxxxxxxx' #20160513160750sel
阅读全文
摘要:TIMESTAMPDIFF(MINUTE, 开始时间, 结束时间) as 时间差(单位:分钟数) TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr2) 参数: SECOND 秒 SECONDS MINUTE 分钟 MINUTES HOUR 时间
阅读全文
摘要:select id, phone,time,year(time),month(time), DAY(time),TIME(time) from user where phone='xxxxxx' #分别取年、月、日、时间select id, phone,time from user where ph
阅读全文
摘要:INITCAP:转换每个字的第一个字符为大写LOWER:转换所有字符为小写UPPER:转换所有字符为人写 eg: LOWER(phone)
阅读全文
摘要:查看以电话号码138开头的电话 select id, phone from user where phone like '138%'
阅读全文
摘要:SELECT id, RIGHT (phone,4) from user where id= 'xxxxxx'
阅读全文
摘要:addtime='2016-09-03 18:12:44' substr(addtime,1,10) as 创建日期 SUBSTR(string, string charcter, number of charcters)参数含义:string:为字符列或字符串表达式string charcter:
阅读全文
摘要:YEAR(CURDATE())-YEAR(addtime)-(RIGHT(CURDATE(),5) SELECT id, YEAR(CURDATE())-YEAR(addtime)-(RIGHT(CURDATE(),5)<RIGHT(addtime,5)) FROM user where id='109480' 来自:http://www.cnblogs.com/fenglie/p/3...
阅读全文
摘要:#获得当前日期+时间(date + time)函数select now()#获得当前时间戳函数select current_timestamp, current_timestamp()#Date/Time to Str(日期/时间转换为字符串)函数select date_format('2008-0
阅读全文
摘要:select * from xi_table into outfile ’d:test.xls’
阅读全文
摘要:一、查看MySQL数据库服务器和数据库MySQL字符集。 show variables like "%char%" 二、查看MySQL数据表(table)的MySQL字符集。 show table status from sqlstudy_db like "%countries%" 三、查看MySQ
阅读全文
摘要:数据库中的函数研究 1)SQL 拥有很多可用于计数和计算的内建函数 2)常用函数: 3)avg() 返回数值列的平均值 语法:select avg(列名)from table_name 示例: select avg(price) as priceAverage from table_name select ProductName, Price from table_name where Pr...
阅读全文

浙公网安备 33010602011771号