MySql学习之简单关键字、检索、通配

来源:互联网 发布:知乎 大提琴 专辑 编辑:程序博客网 时间:2024/06/05 16:08
关键字USE、 SHOW

--查看所有数据库
   SHOW DATABASES
   
--选择数据库
    USE  [数据库名]     eg: USE smsota


--显示数据库中所有表
     USE  [数据库名];
     SHOW TABLES;   


--显示表中所有的列项
    USE  [数据库名];
    SHOW COLUMNS  FROM [表名]
    等同于DESCRIBE [表名]
    eg:   SHOW COLUMNS  FROM  tcharge

关键字distinct
   eg  select distinct procId from products
    只返回不通的procId,去掉重复的



关键字limit
eg:    seletct procid from products limit 5;
          只返回满足条件的前5行结果
         select procid from products limit 1,3;
         只返回从第二行开始的 3行满足条件的结    果。1是起始行(从0起始),3是行数。
         limit 1,3 等效于 limit 3 offset 1


检索
select procId from order by procId
select procId,proName from order by procId,proName

select procId,procPrice from order by procPrice DESC, procId ;按procPrice 降序排列,再按procId升序排列



通配符

1、多字符通配符

select procId,ProcName from products where procName like '%oreint%'; //区分大小写,不能匹配NULL


2、单字符通配符

select procId,ProcName from products where procName like '_oreint_'; //区分大小写,不能匹配NULL























 
   
     

0 0
原创粉丝点击