我有以下SQL表:如何在考慮到SQL中的另一列的情況下選擇列中的下一個可用值?
bid btype Name world vi
---|----|------------ |--------|---------
1 | 1 | Business 1 | 0 | 44
2 | 4 | Business 2 | 0 | 55
5 | 5 | Business 3 | 0 | 23
3 | 1 | Business 4 | 1 | 99
4 | 2 | Business 5 | 0 | 12
6 | 3 | Business 6 | 0 | 14
7 | 2 | Business 7 | 1 | 55
8 | 1 | Business 8 | 2 | 66
9 | 2 | Business 9 | 2 | 77
10 | 1 | Business 10 | 3 | 88
我想是根據其「BTYPE」中的「世界」欄目逐漸增加值,例如每一行與中值0開始「世界專欄 ,因爲這是第一次插入」btype「列中的這樣的值,我想要的是檢查是否已經插入了」btype「,以便」世界「列不再取值爲0 1等等...... 我想要實現的是,不能有兩行與同一個「世界」共享相同的「btype」,「btype」可以是相同的,但不是「世界」,它必須有所不同,我想 它逐漸增加。
我會怎樣做這樣的事情?
您通常不會存儲派生數據。 – Strawberry
沒有辦法做到這一點呢? – ThreeKingz
也許你應該使用輔助自動增量。請參閱http://dev.mysql.com/doc/refman/5.7/en/example-auto-increment.html – Barmar