PrepZone Logo
PrepZone
Back to Database

Database · Hard

Exchange seats between two passengers (swap update pattern).

DatabaseSQL QueriesStaff

Answer preview

Swap adjacent seats with arithmetic, not a join: odd ids move up one, even ids move down one, and the final odd id stays put.…