CREATE TABLE students ( code numeric(5,
- Размер: 73 Кб
- Количество слайдов: 9
Описание презентации CREATE TABLE students ( code numeric(5, по слайдам
CREATE TABLE students ( code numeric(5, 0) PRIMARY KEY , fio character(30) NOT NULL, ) CREATE TABLE subjects ( code numeric(5, 0) PRIMARY KEY , name character(30) NOT NULL, ) CREATE TABLE grades ( code_stud numeric(5, 0 ) REFERENCES students (code) , code_ subj numeric(5, 0) REFERENCES subjects (code) , grade numeric(2, 0), )
SELECT * FROM students INNER JOIN grades on TRUE Декартово произведение
Внутреннее соединение SELECT * FROM students INNER JOIN grades ON students. code=grades. code_stud SELECT students. fio, grades. code_subj, grades. grade FROM students INNER JOIN grades ON students. code=grades. code_stud
Декартово произведение SELECT * FROM subjects INNER JOIN grades ON true
Внутреннее соединение SELECT * FROM subjects INNER JOIN grades ON subjects. code=grades. code_subj SELECT subjects. name, grades. code_stud, grades. grade FROM subjects INNER JOIN grades ON subjects. code=grades. code_subj
Левое внешнее соединение SELECT students. fio, grades. code_subj, grades. grade FROM students LEFT OUTER JOIN grades ON students. code=grades. code_stud SELECT subjects. name, grades. code_stud, grades. grade FROM subjects LEFT OUTER JOIN grades ON subjects. code=grades. code_subj
Правое внешнее соединение SELECT grades. code_subj, grades. grade, students. fio FROM grades RIGHT OUTER JOIN students ON grades. code_stud=students. code SELECT grades. code_stud, grades. grade, subjects. name FROM grades RIGHT OUTER JOIN subjects ON grades. code_subj=subjects. code
Соединение трех таблиц SELECT students. fio, subjects. name, grades. grade FROM (students INNER JOIN grades ON students. code=grades. code_stud) INNER JOIN subjects ON grades. code_subj=subjects. code
Использование псевдонимов, фильтра WHERE SELECT st. fio, su. name, g. grade FROM (students as st INNER JOIN grades as g ON st. code=g. code_stud) INNER JOIN subjects as su ON g. code_subj=su. code WHERE g. grade>