exists

MySQL多表查询

眉间皱痕 提交于 2019-11-29 07:38:37
MySQL多表查询 建表与数据准备 #建表 create table department( #部门表 id int, name varchar(20) ); create table employee( #员工表 id int primary key auto_increment, name varchar(20), sex enum('male','female') not null default 'male', age int, dep_id int ); #插入数据 insert into department values (200,'技术'), (201,'人力资源'), (202,'销售'), (203,'运营'); insert into employee(name,sex,age,dep_id) values ('daxia','female',18,200), ('anwen','male',23,201), ('wudi','male',38,201), ('yage','female',23,202), ('dafei','male',18,200), ('jingyu','female',18,204) ; #查看表结构和数据 mysql> desc department; +-------+-------------+------+-----+----

多表查询

大城市里の小女人 提交于 2019-11-29 07:37:40
多表查询 一、多表连接查询 准备表 #建表 create table department( id int, name varchar(20) ); create table employee( id int primary key auto_increment, name varchar(20), sex enum('male','female') not null default 'male', age int, dep_id int ); #插入数据 insert into department values (200,'技术'), (201,'人力资源'), (202,'销售'), (203,'运营'); insert into employee(name,sex,age,dep_id) values ('egon','male',18,200), ('alex','female',48,201), ('wupeiqi','male',38,201), ('yuanhao','female',28,202), ('liwenzhou','male',18,200), ('jingliyang','female',18,204) ; #查看表结构和数据 mysql> desc department; +-------+-------------+------+-----+--

第4章 DDL数据定义

瘦欲@ 提交于 2019-11-29 07:06:38
第 4 章 DDL 数据定义 4.1 创建数据库 1 )创建一个数据库,数据库在 HDFS 上的默认存储路径是 /user/hive/warehouse/*.db 。 hive (default)> create database db_hive; 2 )避免要创建的数据库已经存在错误,增加 if not exists 判断。(标准写法) hive (default)> create database db_hive; FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Database db_hive already exists hive (default)> create database if not exists db_hive; 3 )创建一个数据库,指定数据库在 HDFS 上存放的位置 hive (default)> create database db_hive2 location '/db_hive2.db'; 4.2 查询数据库 4.2.1 显示数据库   1 .显示数据库 hive> show databases;   2 .过滤显示查询的数据库 hive> show databases like 'db_hive*'; OK db_hive

Mysql高手系列 - 第4天:DDL常见操作汇总

女生的网名这么多〃 提交于 2019-11-29 06:38:21
这是Mysql系列第4篇。 环境:mysql5.7.25,cmd命令中进行演示。 DDL:Data Define Language数据定义语言,主要用来对数据库、表进行一些管理操作。 如:建库、删库、建表、修改表、删除表、对列的增删改等等。 文中涉及到的语法用[]包含的内容属于可选项,下面做详细说明。 库的管理 创建库 create database [if not exists] 库名; 删除库 drop databases [if exists] 库名; 建库通用的写法 drop database if exists 旧库名; create database 新库名; 示例 mysql> show databases like 'javacode2018'; +-------------------------+ | Database (javacode2018) | +-------------------------+ | javacode2018 | +-------------------------+ 1 row in set (0.00 sec) mysql> drop database if exists javacode2018; Query OK, 0 rows affected (0.00 sec) mysql> show databases like

数据仓库

ε祈祈猫儿з 提交于 2019-11-29 05:05:48
1.1数据仓库概念 什么是数据仓库? 数据仓库本身并不“生产”任何数据,同时自身也不需要“消费”任何的数据,数据来源于外部,并且开放给外部应用 目的? 构建面向分析的集成化数据环境,主要职责是做分析,对仓库里面的数据来做分析,数据分析可以支持我们做决策 数据分析特征: (1)面向主题:数据分析有一定范围,需要选取一定的主题进行分析(比如:我们针对订单分析,那么可能跟我们的商品表关系不大,只需要围绕订单分析) (2)继承性:集成各个其他方面关联的一些数据,(比如:我们分析订单购买人情况,就涉及到客户的基本信息;数据出现交叉,那么就将数据集成到一起,需要什么选取什么) (3)非易失性:数据分析,主要分析过去已经发生的数据,都是即成的事实 (4)时变性:随着时间的发展,数的形态也在发生变化,数据的分析的手段也要变化 数据仓库与数据的区别: 数据库:OLTP,联机事务处理,数据库主要的功能就是用来做事务处理,主要负责频繁的增删改查 数据仓库:OLAP,连接分析处理,不需要做事务的保证,主要职责就是做数据的分析,面向分析 首先要明白,数据仓库的出现,并不是要取代数据库。 数据库是面向事务的设计,数据仓库是面向主题设计的。 数据库一般存储业务数据,数据仓库存储的一般是历史数据。 数据库设计是尽量避免冗余,一般针对某一业务应用进行设计,比如一张简单的User表,记录用户名、密码等简单数据即可

Exists 和Not Exists使用

偶尔善良 提交于 2019-11-29 04:46:14
描述:exists表示()内子查询语句返回结果不为空说明where条件成立就会执行主sql语句,如果为空就表示where条件不成立,sql语句就不会执行。not exists和exists相反,子查询语句结果为空,则表示where条件成立,执行sql语句。负责不执行。 使用: 来源: https://www.cnblogs.com/lovelySteelPot/p/11454580.html

How to check if a file exists on a server using c# and the WebClient class

谁说胖子不能爱 提交于 2019-11-29 03:07:17
In my application I use the WebClient class to download files from a Webserver by simply calling the DownloadFile method. Now I need to check whether a certain file exists prior to downloading it (or in case I just want to make sure that it exists). I've got two questions with that: What is the best way to check whether a file exists on a server without transfering to much data across the wire? (It's quite a huge number of files I need to check) Is there a way to get the size of a given remote file without downloading it? Thanks in advance! Tim Robinson WebClient is fairly limited; if you

How to check if a row exists in a PostgreSQL stored procedure?

旧时模样 提交于 2019-11-29 02:48:33
问题 I writing a stored procedure in postgres where I need to check if a row exists then act accordingly. something along the line. IF SELECT * FROM foo WHERE x = 'abc' AND y = 'xyz' THEN -- do something here ELSE -- do something else END; I have googled a bit but got no good hits. 回答1: Use PERFORM and the FOUND automatic variable: PERFORM * FROM foo WHERE x = 'abc' AND y = 'xyz'; IF FOUND THEN .... END IF; This will succeed if one or more rows is returned. If you want to constrain the result to

MySQL数据查询之多表查询

大憨熊 提交于 2019-11-29 01:32:30
多表查询 多表联合查询 #创建部门 CREATE TABLE IF NOT EXISTS dept ( did int not null auto_increment PRIMARY KEY, dname VARCHAR(50) not null COMMENT '部门名称' )ENGINE=INNODB DEFAULT charset utf8; #添加部门数据 INSERT INTO `dept` VALUES ('1', '教学部'); INSERT INTO `dept` VALUES ('2', '销售部'); INSERT INTO `dept` VALUES ('3', '市场部'); INSERT INTO `dept` VALUES ('4', '人事部'); INSERT INTO `dept` VALUES ('5', '鼓励部'); -- 创建人员 DROP TABLE IF EXISTS `person`; CREATE TABLE `person` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `age` tinyint(4) DEFAULT '0', `sex` enum('男','女','人妖') NOT NULL DEFAULT '人妖', `salary`

Checking whether an item does not exist in another table

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 01:05:01
My tables are set up something like this: table name: process fields: name, id_string table name: value_seach fields: id_string, value I want to construct a select statement that will display all of the process names (with it's respective id_string) that do not have an entry in value_search. The id_string in the process table can be null , and still have a name, but those need to be excluded if possible. The id_string in value_search can never be null How do I do this? In general if you want rows that don't exist in another table, then LEFT JOIN the other table and WHERE ... IS NULL to a