易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql中INSTR函数的用法

mysql中INSTR函数的用法
INSTR(字段名, 字符串)
这个函数返回字符串在某一个字段的内容中的位置, 没有找到字符串返回0,否则返回位置(从1开始)
SELECT * from tblTopic ORDER BY INSTR( topicTitle, 'ha' ) > 0 DESC
SELECT INSTR( topicTitle, 'ha' ) from tblTopic
mysql中使用instr配合IN排序
将instr结果作为一列,按其排序
select id,1 from world_guide where id = 32
union
select * from
(select id, instr('30,35,31,',id+',') as d from
world_blog where id in (30,35,31) order by d) as t;
输出
+----+---+
| id | 1 |
+----+---+
| 32 | 1 |
| 30 | 1 |
| 35 | 4 |
| 31 | 7 |
+----+---+
4 rows in set, 6 warnings (0.02 sec)
表A 
字段:姓名 name
  张三
  王五
表B
字段:标题 title 
  信息一 张三发布
  信息二 王五发布
  信息三 张三发布
排行榜,按表A的姓名 like %‘name’% 匹配 表B的 title 的条数进行排序,
排行榜样例
张三 2
王五 1
select 姓名,count(b.title) from a inner join b on instr(b.title,a.姓名)>0
group by 姓名
order by count(b.title)
 
select name,(select count(*) from 表B where instr(title,表A.name)
from 表A
order by 2 desc


相关文档:

MySQL最基础知识记录

一.安装
rpm方式
rpm -ivf MySQL*
tar方式
tar xzvf mysql-x.xx.tar.gz
cd mysqlp-x.xx    生成makefile
./congigure   
make              编译
 
make install
mysql_install_db
二.启动、关闭
ser ......

查询mysql数据库的大小

(1)INFORMATION_SCHEMA
select (sum(data_length) + sum(index_length))/(1024*1024) from INFORMATION_SCHEMA.`TABLES` where table_schema =  'your_table_schema' and table_name like 'your_table_name';
(2)show table status like '';
try {
Class.forName("com.mysql.jdbc.Driver");
......

mysql基本命令

mysql 基本命令
第一招、mysql服务的启动和停止
net stop mysql
net start mysql
第二招、登陆mysql
语法如下: mysql -u用户名 -p用户密码
键入命令mysql -uroot -p, 回车后提示你输入密码,输入12345,然后回车即可进入到mysql中了,mysql的提示符是:
mysql>
注意,如果是连接到另外的机器上,则需要 ......

mysql字符集问题

MySQL的字符集支持(Character Set Support)有两个方面:
     字符集(Character set)和排序方式(Collation)。
对于字符集的支持细化到四个层次:
     服务器(server),数据库(database),数据表(table)和连接(connection)。
1.MySQL默认字符集
  MySQL对于字符集的 ......

Mysql用户添加及权限分配

     格式:grant [PRIVILEGES]  on [databaseName.tableName] to [userName]@[host] identified by [password] with grant option;
     eg1:  grant select on mysql.user to wqh@localhost
     eg2:GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号