MySQL duomenų bazės (BIT)
Užklausos
SELECT * FROM students s LEFT JOIN `Groups` g ON s.group_id=g.id
SELECT l.name,g.name FROM lecturers l LEFT JOIN group_lecturer gl ON l.id=gl.lecturer_id LEFT JOIN `groups` g ON g.id=gl.group_id
SELECT l.name,g.name FROM `groups` g LEFT JOIN group_lecturer gl ON g.id=gl.group_id LEFT JOIN lecturers l ON l.id=gl.lecturer_id
SELECT city FROM students WHERE name="Mindaugas"
SELECT g.name, count(*) FROM `groups` g LEFT JOIN students s ON g.id=s.group_id GROUP BY g.name
SELECT g.name, count(s.id) FROM `groups` g LEFT JOIN students s ON g.id=s.group_id GROUP BY g.name
SELECT l.name, count(s.id) as kiekis FROM lecturers l
LEFT JOIN group_lecturer gl ON l.id=gl.lecturer_id
LEFT JOIN `groups` g ON gl.group_id=g.id
LEFT JOIN students s ON g.id=s.group_id
GROUP BY l.id
HAVING kiekis=0
SELECT l.name, count(s.id) as kiekis
FROM lecturers l
LEFT JOIN group_lecturer gl ON l.id=gl.lecturer_id
LEFT JOIN `groups` g ON gl.group_id=g.id
LEFT JOIN students s ON g.id=s.group_id
WHERE s.city like "Klaipėda"
GROUP BY l.id
HAVING kiekis!=0