Skip to main content

4 posts tagged with "sql"

View All Tags

three value prediate and sql

· 2 min read

三值逻辑

三值的谓词: 谓词求值后有三个元素{T,F,U} ,也就是true , false , 和unknow

求值和谓词

SELECT 1=NULL

在mysql , 这个会返回一行,这行是值是null

① 然后根据规范 where casehaving 子句都只取三值逻辑真值中的true

   SELECT 1 NOT IN (1,  NULL)    ## false 所以不会被条件筛选出来
SELECT 1 NOT IN ( NULL) ## null , 因为上面的规则①所以也不会被筛选出来

所以在where子句中使用not innot int 中包含null的时候会筛选不出来

exist 规范规定exist是个二值函数,所以要映射成true或者false , mysql中则是只要返回一行真值就是true

pushdown

· One min read

谓词下推:

为什么可以谓词下推?

因为交换律结合律

怎么下推,也就是触发条件?

rule instance

语义

sql join

· 2 min read

什么是语言 ?

inductively defined sets

inductively defined sets 是由三部分组成

  • 1 一个初始集合
  • 2 一个生成规则
  • 3 声明除了这个1 2两个条件之外没有其他的元素属于这个集合

例子

自然数集合

{0 , 1 , 2 ...}

这个集合 首先一个元素

{0}

然后是规则

suc(i) 

left join 和right join的区别?

我是大学学通信工程的,有些数学概念还是不太全,只能偶尔补一下啦. 我一直找left joinright join的定义或者rfc文件. 就像c语言看c89 c99一样,你看sql也可以看sql 99, 这个文档有描述什么是left join

Let XN1 and XN2 be effective distinct names for X1 and X2, respectively. Let TN be an effective
name for T.
Case:
a) If INNER or <cross join> is specified, then let S be the multiset of rows of T.
b) If LEFT is specified, then let S be the multiset of rows resulting from:
SELECT FROM T
UNION ALL
SELECT FROM X1
c) If RIGHT is specified, then let S be the multiset of rows resulting from:
SELECT FROM T
UNION ALL
SELECT FROM X2

相关阅读

一个sql的组成

· One min read

前言

写了很多mysql的sql,看了很多blog,兜兜转转,发现很多都是不太严谨的. 很多解释也是有点盲人摸象的感觉,不能说是错但是有些片面.

BNF和indeductly define set

select  name from  table where table.file =1;

三值