《Mysql应用MySql数据库中Select用法小结》要点:
本文介绍了Mysql应用MySql数据库中Select用法小结,希望对您有用。如果有疑问,可以联系我们。
MYSQL必读一、条件筛选
MYSQL必读1、数字筛选:sql = "Select * from [sheet1$] Where 销售单价 > 100"
MYSQL必读2、字符条件:sql = "Select * from [sheet1$] Where 物品名称 ='挡泥板'"
MYSQL必读3、日期条件:sql = "Select * from [sheet1$] Where 物品名称 ='挡泥板'"
MYSQL必读4、区间条件:sql = "Select * from [sheet1$] Where 出库日期 between #2005-1-4# and #2005-1-10#"
MYSQL必读5、多个条件:用and,OR连接
MYSQL必读
'sql = "Select * from [sheet1$] Where 出库日期 between #2005-1-4# and #2005-1-10# and 销售单价>100"
MYSQL必读6、模糊条件:%表示任意多个字符,_(下划线)表示单个占位符
MYSQL必读
'sql = "Select * from [sheet1$] Where 物品名称 like '%扶手%'"
MYSQL必读7、插入变量查询:
MYSQL必读
'sr = "挡泥板"
'sql = "Select * from [sheet1$] Where 物品名称 ='" & sr & "'"
MYSQL必读8、在字符串组里:
MYSQL必读
'sql = "Select * from [sheet1$] Where 物品名称 in('车衣','扶手箱')"
MYSQL必读9、借用函数优化:
MYSQL必读
'sql = "Select * from [sheet1$] Where left(物品代码,3)='028'"
MYSQL必读二、指定筛选
MYSQL必读1、筛选全部字段:*表示全部字段
MYSQL必读
'sql = "Select * from ChuKu"
MYSQL必读2、筛选指定字段:在from前面列出要显示的所有字段,如果要跳过的用""""
MYSQL必读
'sql = "Select """",出库日期,"""",物品代码,"""",规格,单位 from ChuKu"
MYSQL必读3、筛选不重复的:Distinct 字段名 筛选不重复的记录
MYSQL必读
'sql = "Select Distinct """",物品代码 from ChuKu"
MYSQL必读4、按百分比筛选:Top N percent 可以显示前百分之N的记录
MYSQL必读
'sql = "Select top 30 Percent * from ChuKu"
MYSQL必读'对筛选的字段用函数进行进一步的处理和格式化
MYSQL必读
'sql = "Select ID,Format(出库日期,""yyyy-mm-dd"") from ChuKu"
MYSQL必读5、排序:Desc降序,Asc升序
MYSQL必读
'sql = "Select * from ChuKu Order by 出库日期 asc,销售单价 desc"
'sql = "Select Top 10 * from ChuKu Order by 出库日期 asc,销售单价 desc" '筛选销售数量前10()
MYSQL必读三、分组显示
MYSQL必读Group by 可以配合函数进行分组求和,分组求最大值等.
MYSQL必读
'sql = "Select """","""",物品代码,"""","""","""",sum(出库数量) from ChuKu group by 物品代码" ' 跳过的用""""
MYSQL必读按条件显示分组记录
MYSQL必读
'sql = "Select """","""",物品代码,"""","""","""",sum(出库数量) from ChuKu group by 物品代码 HAVING sum(出库数量)>=3"
MYSQL必读以上所述是小编给大家介绍的MySql数据库中Select用法小结,希望对大家有所赞助,如果大家有任何疑问请给我留言,小编会及时回复大家的.在此也非常感谢大家对维易PHP网站的支持!
维易PHP培训学院每天发布《Mysql应用MySql数据库中Select用法小结》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。