MYsql数据库基本使用笔记.docVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
MYsql数据库基本使用笔记 MYsql数据库笔记 创建数据库: create table store (store_nam varchar(50),sales decima(10,2),date date); 插入数据: insert into store values(Los Angeles,1500,1999-01-05); insert into store values(San Diego,250,1999-01-07); insert into store values(Los Angeles,300,1999-01-08); insert into store values(Boston,700,1999-01-08); insert into store values(Boss,600,1999-01-12); insert into store values(Bas,450,1999-01-25); 查询语句: select store_nam from store;-----按店名查询 select distinct store_nam from store;----查询不重复的店名 select * from store where sales1000;----查询营业额超过1,000 的资料 选出所有Sales 高于$1,000 或是Sales 在$500 及$275 之间的资料的话: select * from store where sales1000 or (sales500 and sales275); select * from store where sales1000 or (sales between 275 and 500); 含盖Los Angeles 或SanDiego 的资料 select * from store where store_nam in(Los Angeles,San Diego); 表格中找出所有介于January 6,1999 及January 10, 1999 中的资料 select * from store where date between 1999-01-06 and 1999-01-10; 所有含有AN 这个字串的资料 select * from store where store_nam like %an%; 所有含有以L开头的store_nam(店名) select * from store where store_nam like L%; 所有含O结尾的店名资料 select * from store where store_nam like %o; 所有以B开头,s结尾的字符串,中间有两个字符用_ _用两个下划线代替格式 select * from store where store_nam like B__s; 依照Sales 栏位的由大往小列出Store表格中的资料 select * from store order by sales desc; 依照Sales 栏位的由小往大列出Store表格中的资料 select * from store order by sales asc; 求出Sales 栏位的总合: select sum(sales) from store; 示范表格中有几笔store_nam 栏不是空白的资料时: select count(store_nam) from store where store_nam is not null; 如果我们要找出我们的表格中有多少个不同的store_name,我们就打入: select count(distinct store_nam) from store; 我们现在回到函数上。记得我们用SUM 这个指令来算出所有的Sales (营业额)吧!如果我 们的需求变成是要算出每一间店(store_name) 的营业额(sales),那怎么办呢?在这个情 况下,我们要做到两件事:第一,我们对于store_name 及Sales 这两个栏位都要选出。 第二,我们需要确认所有的sales 都要依照各个store_name 来分开算。这个语法为: select store_nam,sum(sales) from store group by store_nam;---计算出每间店面的营业额且按店面排列 我们可能只需要知道哪些店的营业额有超过$1,500 select store_nam,sum(sales) from store group by store_nam having sum(sales) 1500; 新建一个新表:graphy create table graphy(regio

文档评论(0)

htfyzc + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档