zoukankan      html  css  js  c++  java
  • 简单的查询语句

    1.查询全部的行和列,*代表所有的行和列

    select * from 表名

    2、查询部分行和列,部分行使用where来限制、部分列使用列名来限制

    select * from 表名 where 行名='条件'   不是

    select 列名1,列名2,列名3,列名3, from 表名

    wehre  行名=‘条件’     是

    “=”比较运算符,将左右两边的值进行相比,完全一致的会显示出来

    同理

    select * from 表名 where 行名<>'条件'   不是

    select 列名1,列名2, from 表名 where 行名<>'条件'   不是

    <> 比较运算符不等于    也可以使用“!=”

    3.别名

    (1)使用as关键字

    select id as 编号,name as 名字,from  表名

    (2)=赋值从左至右

    select   编号=id,名字=name ,from  表名

    (3)使用“空格”

    select id 编号 ,name 名字,from  表名

    4.查询为null值

    seclet * from 表名 where 列名 is null

    5.如果原来有数据,而后又被删除,那么使用is null 能否查询到

    select * from   表名 where 列名 is null or 列名=‘’

    --is null 与‘’区别  

    --is null:从未录入过数据,没有地址

    --' ':录入过数据,而后被删除,是有地址的

    练习

    use demo --使用数据库
    go --开始
    select * from text --查询所有的行和列

    select * from text where name='小明' --只选择小明
    select * from text where name<>'小明' --小明除外
    select id 序号,name 名字, sex 性别 from text --加别名

  • 相关阅读:
    js调试工具
    学习之compare:c#和c++中各种compare方法
    individual program总结2.0
    individual program总结
    C语言编程—自动生成四则运算升级版
    jQuery Validate(一)
    Java_得到GET和POST请求URL和参数列表
    jQuery Validate(二)
    MySQL_使用时遇到的问题汇总
    jQuery Validate(三)
  • 原文地址:https://www.cnblogs.com/tangtangsimida/p/9471776.html
Copyright © 2011-2022 走看看