黑马程序员——sql数据库学习日志

---------------------- Windows Phone 7手机开发.Net培训、期待与您交流! -------------------

一、基本的数据库操作:

1、  插入:insertinto 表名 (字段1,字段2,。。) values (‘’,’’,..)

2、  修改:upadate 表名 set 字段1=‘’,字段2=‘’,.. where 条件

3、  删除:a)删除表中数据:deletefrom 表名 where 条件

      b)将整个表删除,以及其中的字段:drop 表名

         4、查询:select 条件 from 表名 where 条件

                   A、排序:order by 用‘,’号隔离多个排序条件,where必须放在order by 之前

                     ASC升序,DESC是降序;

                   B、模糊查询:like

                            a、单字符匹配:‘_’,

                            b、多自负匹配:‘%’

                   C、多值匹配:select* from 表名 where 字段名 in (10,20,30…)

                   D、数据分组:groupby 放在where语句之后

                   E、限制结果行数;top

                   F、联合结果集:union,union默认会合并重复字段,如果不想重复,使用union all

二、函数:

   1、常用聚合函数;

           Count()计算数量

           Sum()求和

           Max()计算最大值

           Min()计算最小值

     Avg()求平均数等

  2、数字函数:

    ABS()求绝对值

          Ceiling()舍入最大整数

          Floor()舍入最小整数

          Round()四舍五入

          Len()计算字符串的长度

          Lower(),upper()转小写,大写

          Ltrim(),Rtrim()去掉做空个,右空格

          Substring(string,开始位置,截取长度

 3、日期函数

          Getdate()取当前日期

          Dateadd(单位,number,date)日期的加减

          Datediff(dateparte,startdate,enddate)计算俩日期之间的差额

          Datepart(datepart,,)取日期的特定部分

4、流控函数

         IsNull(字段,‘’)如果字段是空,就赋值’’;

         Case表达式

         When值 then 怎么样

         When…. Then …

         Else怎么样

         End;

         相当于if…else…


------------------------- Windows Phone 7手机开发.Net培训、期待与您交流! ----------------------

详细请查看:http://net.itheima.com/

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>cn.itcast.parent</groupId> <artifactId>itcast-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>cn.itcast</groupId> <artifactId>travel</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <!-- Jackson Json处理工具包 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.7</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> </dependency> </dependencies> <build> <plugins> <!-- 配置Tomcat插件 --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8080</port> <path>/</path> </configuration> </plugin> </plugins> </build> </project>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值