我有學生和班級。 每個學生有一個exam_place_id和教室 每個教室都有自己的坐位限制。 所以我必須根據學生的數量給予每個學生教室。如何給mysql數據庫中限制人數賦予不同的值?
例如在伊斯坦布爾(exam_place_id = 11)我現在有530名學生。
和類配額就像
Class 1 - number of students can sit : 19
Class 2 - number of students can sit : 26
Class 3 - number of students can sit : 29
Class 4 - number of students can sit : 24
Class 5 - number of students can sit : 31
Class 6 - number of students can sit : 22
Class 7 - number of students can sit : 24
Class 8 - number of students can sit : 29
Class 9 - number of students can sit : 24
Class 10 - number of students can sit : 25
Class 11 - number of students can sit : 28
Class 12 - number of students can sit : 24
Class 13 - number of students can sit : 22
Class 14 - number of students can sit : 28
Class 15 - number of students can sit : 28
Class 16 - number of students can sit : 27
Class 17 - number of students can sit : 64
Class 18 - number of students can sit : 64
所以依班配額我會更新學生的班級
update students set class = "Class 1" where payStatus = 1 and is_completed = 1 and exam_place_id =11 and class = 0 limit 19
update users set class = "Class 2" where payStatus = 1 and is_completed = 1 and exam_place_id =11 and class = 0 limit 26
所以我會不會從表19級的用戶,並檢查他們的其中的類值爲零(未定義)我將用我的班級號碼更新它們。但沒有工作它覆蓋之前,即使我嘗試更新學生與 class = 0
什麼是我可以嘗試的任何其他解決方案?