关系代数和sql语句对应关系

时间:2022-06-01 21:45:14
关系代数运算符           对应sql语句
聚合操作  
∪ (UNION)并  
∩ (INTERSECTION)交  
-  (DIFFERENCE)差  
× (Cartesian PRODUCT)笛卡尔积     from
纯关系操作  
π (PROJECT)投影           select
σ (SELECT)选择            where
⋈ (JOIN)链接   JOIN(mysql> SELECT a.age, b.author FROM books a INNER JOIN books2 b ON a.age>25;)
÷ (DIVISION)除  exists 和not exists(select * from books A where not exists(select age from books8 B WHERE A.age=B.age);)
   
> 大于  
>=大于等于  
< 小于  
<=小于等于  
= 等于  
!=不等于  
∧ 与  
∨ 或  
¬ 非  
between          在两个值范围内查找  
like                按通配符查找  
regexp            按正则表达式查找  
组合条件 and, or  select * from table_name where coll = xxx and col2 = xx or col3 > x;