Базы данных
Реляционная алгебра
select distinct A1, A2, …, An from R
select A1, A2, …, An from R -- с повторениями
select * from R where Condition
select …, b as a, … from R
select * from R1 union select * from R2
select * from R1 union all select * from R2
-- с повторениями
select * from R1 intersect select * from R2
select * from R1 intersect all select * from R2
-- с повторениями
select * from R1 except select * from R2
select * from R1 except all select * from R2
-- с повторениями
select *, expr as A from R
select X, Function(A) as A from R group by X
select count(*) … -- подсчет всех
select count(distinct A) … -- подсчет различных
select count(q) … -- подсчет не null
… having condition -- фильтрация после агрегации
… order by attrs -- сортировка
select * from R1 cross join R2
select * from R1, R2
select * from R1 natural join R2
select * from R1 inner join R2 using (A)
select * from R1 inner join R2 on R1.A = R2.A
select * from R1 inner join R2 on θ
select * from R1 full [outer] join R2 using (...)
select * from R1 full [outer] join R2 on θ
select * from R1 left [outer] join R2 using (...)
select * from R1 left [outer] join R2 on θ
select * from R1 right [outer] join R2 using (...)
select * from R1 right [outer] join R2 on θ
select
P.Name as Name,
F.Birthday as FatherBirthday,
M.Birthday as MotherBirthday
from
Persons P
inner join Persons F on p.FatherId = F.id
inner join Persons M on p.MotherId = M.id
select P.Name as Name
from (предыдущий запрос) P
where P.MotherBirthday = P.FatherBirthday
select P1.Name as Name1, P2.Name as Name2
from Persons P1
inner join Persons P2
on P1.MotherId = P2.MotherId
and P1.FatherId = P2.FatherId
and P1.Id < P2.Id
select P.Name as Name, f.Name as ParentName
from Persons P
inner join Persons f on P.FatherId = f.Id
union
select P.Name as Name, m.Name as ParentName
from Persons P
inner join Persons m on P.MotherId = m.Id
select [distinct]
… as …, … as … -- ε, π и ρ
from
R1 A1
ххх join R2 A2 on … -- ⊗
…
ххх join Rn An on … -- ⊗
where
… -- σ