🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 25:

Move a Student to Another Section

MariaDB
Section 1585 of the Database Systems course is full (40 of 40), and section 1586 of the same course has free seats. Student 10 moves from 1585 to 1586. The task runs on small copies of sections (with the counter enrolled_count) and enrollments.
Three changes must be saved together or not at all:
1. in enrollments, change section_id of the student's enrollment from 1585 to 1586;
2. decrease enrolled_count of section 1585 by 1;
3. increase enrolled_count of section 1586 by 1.
Make them in one transaction.
Expected result Columns: 4 · Rows: 3
enrollment_id student_id section_id enrolled_count

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

The query result will appear here. Ctrl+Enter - Run query