码迷,mamicode.com
首页 > 数据库 > 详细

mySQL简单操作(二)

时间:2019-04-07 16:56:23      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:语句   mys   fun   连接   分组   HERE   UNC   数据   简单操作   

1、like子句

[where clause like ‘%com‘]

  • ‘%‘
  • ‘_‘

2、正则

3、union操作符

用于连接多个select语句,[distinct]删除重复数据

select col1, ......, coln from tbl_name

[where clause]

union [all(默认) / distinct]

select col1, ......, coln from tbl_name

[where clause]

4、order by 排序

select col1, ......, coln from tbl_name

[where clause]

order by col1,...... [ASC(默认) / DESC]

  • gbk(汉字编码字符集)
  • utf-8(万国码):order by convert (col1, ...... using gbk)  [ASC(默认) / DESC]

5、group by 分组语句

select col1, ......, function(coln) from tbl_name

[where clause]

[group by col1]

[having clause]

[order by ......]

6、join 内连接

  • left jpin
  • join 或 inner join
  • right join

以下两句等价:

(1)select tbl1.col1, tbl1.col2, tbl2.col3 

       from tbl_name1 tbl1 join tbl_name2 tbl2 on tbl1.col3 = tbl2.col3

(2)select tbl1.col1, tbl1.col2, tbl2.col3 from tbl_name1 tbl1, tbl_name2 tbl2

       where tbl1.col3 = tbl2.col3

 

mySQL简单操作(二)

标签:语句   mys   fun   连接   分组   HERE   UNC   数据   简单操作   

原文地址:https://www.cnblogs.com/hsiaz/p/10665920.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!