1

この段階でうまく機能する次のSQLがあります。

  INSERT INTO recEntrantStatus (entrantId, roundId, judgeId, notified, voted, enterNextRound)
  SELECT entrantId, (@round + 1), judgeId, 0, 0, 0
  FROM recEntrantStatus
  WHERE roundId = @round
  AND voted = 1
  AND enterNextround = 1

このコードは、enterNextRoundが true であるすべての行をチェックし、それぞれに対して新しい行を作成します。

ただし、次のようにこれを拡張する必要があります。

  1. すべての審査員の 2 番目のテーブル ( tblJudges) をチェックし、すべての審査員 ID の配列 (Id) を取得します。

  2. 上記の例と同じことを行いますが、ステップ 1 で取得した各審査員/審査員 ID に対して上記の各行を作成します。

いつものように、どんな助けや提案も大歓迎です。

ありがとう!

4

1 に答える 1

1

私があなたを正しく理解しているなら、これは役に立つかもしれません:

INSERT INTO recEntrantStatus (entrantId, roundId, judgeId, notified, voted, enterNextRound)
SELECT r.entrantId, (@round + 1), j.judgeId /*Now getting tblJudges Id*/, 0, 0, 0
FROM recEntrantStatus r
    -- Get all of the judges
    CROSS JOIN (SELECT DISTINCT Id AS judgeId FROM tblJudges) AS j
WHERE r.roundId = @round
    AND r.voted = 1 -- Is this based on a judge or an entrant status?
    AND r.enterNextround = 1

以前と同じものを取得していますが、必要に応じて (そして個々のジャッジ ID を使用して) ジャッジの数を掛けただけです。

于 2012-10-10T17:46:54.517 に答える