-1
我正在使用MySQL減去兩個表之間的計數
我如何計算從另一個表中減去記錄。 例如,數= TAB1 - TAB2
表:TAB1
+-------------+----------------+
| studnetId + batchId +
+-------------+----------------+
+ 1 + 1 +
+-------------+----------------+
+ 2 + 1 +
+-------------+----------------+
+ 3 + 1 +
+-------------+----------------+
+ 4 + 1 +
+-------------+----------------+
+ 5 + 2 +
+-------------+----------------+
+ 6 + 2 +
+-------------+----------------+
+ 7 + 2 +
+-------------+----------------+
表:TAB2
+-------------+----------------+
| studnetId + batchId +
+-------------+----------------+
+ 1 + 1 +
+-------------+----------------+
預期結果
+-------------+----------------+
| count + batchId +
+-------------+----------------+
+ 3 + 1 +
+-------------+----------------+
+ 2 + 2 +
+-------------+----------------+
我在計算學生ID – fresher
當'batchId'是'2'時,count不應該是'3'嗎? – sgeddes