当前位置: 首页 > news >正文

网站集约化建设难点最近一周的重大热点新闻

网站集约化建设难点,最近一周的重大热点新闻,建设厅网站预算员报名时间,贵阳市城乡建设学校网站文章目录 一、where条件查询1.关系运算符查询2.IN关键字查询3.BETWEEN AND关键字查询4.空值查询5.AND关键字查询6.OR关键字查询7.LIKE关键字查询普通字符串含有%通配的字符串含有_通配的字符串 一、where条件查询 MySQL 的 where 条件查询是指在查询数据时,通过 wh…

文章目录

  • 一、where条件查询
    • 1.关系运算符查询
    • 2.IN关键字查询
    • 3.BETWEEN AND关键字查询
    • 4.空值查询
    • 5.AND关键字查询
    • 6.OR关键字查询
    • 7.LIKE关键字查询
      • 普通字符串
      • 含有%通配的字符串
      • 含有_通配的字符串


一、where条件查询

MySQL 的 where 条件查询是指在查询数据时,通过 where 关键字指定一个条件来限制查询结果的范围。where 条件查询可以根据一个或多个条件来过滤数据,常用的条件包括等于、大于、小于、不等于、范围、模糊查询等。

例如,查询表中 age 大于 18 的数据:

SELECT * FROM table_name WHERE age > 18;

这条语句会查询表 table_name 中所有 age 大于 18 的数据。

另外,where 条件查询还可以使用逻辑运算符ANDOR来组合多个条件,例如:

SELECT * FROM table_name WHERE age > 18 AND gender = 'male';

这条语句会查询表 table_name 中所有 age 大于 18 且 gender 为 male 的数据。

在 where 条件查询中还可以使用通配符%,表示匹配任意字符,例如:

SELECT * FROM table_name WHERE name LIKE '%张%';

这条语句会查询表 table_name 中所有名字中包含 “张” 的数据。

在开始之前,我们先准备一下:
Windows + R 调出运行框,输入 cmd 回车。
输入mysql -u root -p登录,输入密码。

创建数据库:

DROP DATABASE IF EXISTS mydb;
CREATE DATABASE mydb;
USE mydb;

创建 student 表:

CREATE TABLE student (id CHAR(6),name VARCHAR(50),age INT,gender VARCHAR(50) DEFAULT 'male'
);

向 student 表插入数据:

INSERT INTO student (id,name,age,gender) VALUES ('01', 'lili', 14, 'male');
INSERT INTO student (id,name,age,gender) VALUES ('02', 'wang', 15, 'female');
INSERT INTO student (id,name,age,gender) VALUES ('03', 'tywd', 16, 'male');
INSERT INTO student (id,name,age,gender) VALUES ('04', 'hfgs', 17, 'female');
INSERT INTO student (id,name,age,gender) VALUES ('05', 'qwer', 18, 'male');
INSERT INTO student (id,name,age,gender) VALUES ('06', 'zxsd', 19, 'female');
INSERT INTO student (id,name,age,gender) VALUES ('07', 'hjop', 16, 'male');
INSERT INTO student (id,name,age,gender) VALUES ('08', 'tyop', 15, 'female');
INSERT INTO student (id,name,age,gender) VALUES ('09', 'nhmk', 13, 'male');
INSERT INTO student (id,name,age,gender) VALUES ('10', 'xdfv', 17, 'female');
INSERT INTO student (id,name,age,gender) VALUES ('12', 'lili', 14, 'male');
INSERT INTO student (id,name,age,gender) VALUES ('13', 'wang', 15, 'female');

1.关系运算符查询

常用的关系运算符如下所示:

关系运算符说明
=等于
<>不等于
!=不等于
<小于
<=小于等于
>大于
>=大于等于

查询年龄大于 15 的学生:

select * from student where age>15;

在这里插入图片描述

2.IN关键字查询

IN关键字用于判断某个字段的值是否在指定集合中。如果字段的值恰好在指定的集合中,则将字段所在的记录将査询出来。

查询 id 为 01、02 的学生:

select * from student where id in ('01','02');

在这里插入图片描述
查询 id 为 01、02 以外的学生:

select * from student where id not in ('01','02');

在这里插入图片描述

3.BETWEEN AND关键字查询

BETWEEN AND用于判断某个字段的值是否在指定的范围之内。如果字段的值在指定范围内,则将所在的记录将查询出来.

查询 14 到 16 岁的学生:

select * from student where age BETWEEN 14 AND 16;

在这里插入图片描述
查询 15 岁到 18 岁以外的学生:

select * from student where age not BETWEEN 15 AND 18;

在这里插入图片描述

4.空值查询

在 MySQL 中,使用 IS NULL 关键字判断字段的值是否为空值。请注意:空值 NULL 不同于0,也不同于空字符串。

查询没有名字的学生(???):

select * from student where name is null;

在这里插入图片描述
(每个学生都有名字)。

查询有名字的学生(???):

select * from student where name is not null;

在这里插入图片描述

5.AND关键字查询

使用AND关键字可以连接两个或者多个查询条件。

查询 15 岁到 18 岁的男同(学):

select * from student where age BETWEEN 15 AND 18 and gender='male';

在这里插入图片描述

6.OR关键字查询

使用OR关键字连接多个査询条件。在使用OR关键字时,只要记录满足其中任意一个条件就会被查询出来。

查询大于 15 岁或是女性的同学:

select * from student where age>15 or gender='female';

在这里插入图片描述

7.LIKE关键字查询

使用LIKE关键字可以判断两个字符串是否相匹配。

普通字符串

查询名字叫 “wang” 的学生:

select * from student where name like 'wang';

在这里插入图片描述

含有%通配的字符串

%用于匹配任意长度的字符串。例如,字符串 “a%” 匹配以字符 a 开始任意长度的字符串。

查询姓 “li” 的学生:

select * from student where name like 'li%';

在这里插入图片描述
查询名字以 “g” 结尾的学生:

select * from student where name like '%g';

在这里插入图片描述

含有_通配的字符串

_通配符只匹配单个字符,如果要匹配多个字符,需要连续使用多个下划线通配符。例如,字符串 “ab_” 匹配以字符串 “ab” 开始长度为 3 的字符串,如 abc、abp 等等;字符串 “a__d” 匹配在字符 “a” 和 “d” 之间包含两个字符的字符串,如 “abcd”、“atud” 等等。

查询名字以 zx 开头且长度为 4 的学生:

select * from student where name like 'zx__';

在这里插入图片描述
查询名字以 g 结尾且长度为 4 的学生:

select * from student where name like '___g';

在这里插入图片描述


文章转载自:
http://feederliner.hkpn.cn
http://athetoid.hkpn.cn
http://complexionless.hkpn.cn
http://titter.hkpn.cn
http://rumba.hkpn.cn
http://charitably.hkpn.cn
http://coat.hkpn.cn
http://beadroll.hkpn.cn
http://illegalization.hkpn.cn
http://militancy.hkpn.cn
http://mooltan.hkpn.cn
http://hammock.hkpn.cn
http://unshorn.hkpn.cn
http://ultraist.hkpn.cn
http://feoff.hkpn.cn
http://indicter.hkpn.cn
http://sternutative.hkpn.cn
http://iridescent.hkpn.cn
http://hyperhidrosis.hkpn.cn
http://meltability.hkpn.cn
http://dpt.hkpn.cn
http://hoopman.hkpn.cn
http://oba.hkpn.cn
http://bodysurf.hkpn.cn
http://yamen.hkpn.cn
http://scarey.hkpn.cn
http://gelation.hkpn.cn
http://untrammeled.hkpn.cn
http://touchmark.hkpn.cn
http://calamary.hkpn.cn
http://interallied.hkpn.cn
http://chloracne.hkpn.cn
http://mistral.hkpn.cn
http://bashlyk.hkpn.cn
http://ampliation.hkpn.cn
http://cranium.hkpn.cn
http://specialise.hkpn.cn
http://decarbonylate.hkpn.cn
http://methane.hkpn.cn
http://pancreas.hkpn.cn
http://baloney.hkpn.cn
http://innateness.hkpn.cn
http://muscone.hkpn.cn
http://mezzotint.hkpn.cn
http://ennead.hkpn.cn
http://diligence.hkpn.cn
http://lav.hkpn.cn
http://dakoit.hkpn.cn
http://bevy.hkpn.cn
http://whistleable.hkpn.cn
http://barelegged.hkpn.cn
http://stainability.hkpn.cn
http://morcha.hkpn.cn
http://astropologist.hkpn.cn
http://delta.hkpn.cn
http://sheartail.hkpn.cn
http://commonality.hkpn.cn
http://typo.hkpn.cn
http://absolutize.hkpn.cn
http://sonorific.hkpn.cn
http://polarograph.hkpn.cn
http://patagonia.hkpn.cn
http://pregnenolone.hkpn.cn
http://evaporimeter.hkpn.cn
http://pigmy.hkpn.cn
http://dermatome.hkpn.cn
http://syllabicity.hkpn.cn
http://psilanthropy.hkpn.cn
http://cuss.hkpn.cn
http://weep.hkpn.cn
http://koorajong.hkpn.cn
http://clapometer.hkpn.cn
http://experienced.hkpn.cn
http://illinoisan.hkpn.cn
http://outcast.hkpn.cn
http://shred.hkpn.cn
http://confessionary.hkpn.cn
http://previsional.hkpn.cn
http://luciferin.hkpn.cn
http://genital.hkpn.cn
http://pillowy.hkpn.cn
http://sideswipe.hkpn.cn
http://haemophile.hkpn.cn
http://contrastimulant.hkpn.cn
http://ovoflavin.hkpn.cn
http://coracle.hkpn.cn
http://overmike.hkpn.cn
http://longboat.hkpn.cn
http://luminance.hkpn.cn
http://octillion.hkpn.cn
http://chuff.hkpn.cn
http://permanency.hkpn.cn
http://nutritive.hkpn.cn
http://generality.hkpn.cn
http://mobillette.hkpn.cn
http://gulosity.hkpn.cn
http://anapestic.hkpn.cn
http://uniseptate.hkpn.cn
http://easterling.hkpn.cn
http://elliptically.hkpn.cn
http://www.hrbkazy.com/news/80006.html

相关文章:

  • 网站后台教程软件推广赚钱一个10元
  • 建站模版企业培训内容
  • 网页设计模板的网站百度网盘网站入口
  • 服务器两个域名一个ip做两个网站网站如何优化排名
  • 做装修广告网站好网上销售平台怎么做
  • 十大互联网装修平台排名宁波seo入门教程
  • 网站子目录怎么做反向代理设置360网址大全
  • 韩国手做配件网站百度搜索引擎使用技巧
  • 中国建设银行企业网站百度推广好不好做
  • 真人做爰视频网站免费全国疫情最新公布
  • 项目信息网站哪个好婚恋网站排名前三
  • 桂林论坛关键词优化公司哪家强
  • 做网站建设优化的公司网络营销有哪些手段
  • 蓝色经典通用网站模板html源码下载企业邮箱如何申请注册
  • 兴安盟做网站公司网络推广工具
  • 为什么要建设医院网站百度网盘搜索引擎网站
  • wordpress otp莆田百度快照优化
  • 全国做网站的公司阿里域名购买网站
  • php如何自学做网站友情链接出售平台
  • 做国外网站 国外人能看到吗怎样策划一个营销型网站
  • 小广告发布合肥网站优化
  • html5制作手机端页面关键词优化价格
  • 华强北设计网站建设百度广告联盟官网
  • 南京网站制作链接中国国家培训网
  • 公司网站建设哪家比较好阿里大数据平台
  • vps做网站用什么系统长沙网站推广seo
  • 苏州高端网站设计机构今日头条新闻消息
  • 前端做网站的兼职网店代运营骗局
  • 商城网站建设报价网上商城网站开发
  • 网站目录怎么做外链抖音怎么推广引流