如何为每个学生ID插入5个兴趣ID?

时间:2018-06-25 17:40:28

标签: sql sql-server

我希望能够在Student_Interest表中为每个学生ID插入五个兴趣ID。

我尝试过,但是没有得到30行,而是得到72行(“学生”表中有6个学生,在“兴趣”表中有12个兴趣):

INSERT INTO Student_Interest (Id_Student, Id_Interest, Score)
SELECT 
    Id_Student
    ,Id_Interest
    ,ABS(Checksum(NewID()) % 5) + 1
FROM Student, Interest
ORDER BY NEWID()

感谢您的帮助。

1 个答案:

答案 0 :(得分:3)

您需要的是def play_game(): print("Enter the upper limit for the range of numbers: ") limit = int(input()) number = random.randint(1, limit) print("I'm thinking of a number from 1 to " + str(limit) + "\n") while True: guess = int(input("Your guess: ")) if guess < number: print("Too low.") elif guess > number: print("Too high.") elif guess == number: print("You guessed it in " + str(count) + " tries.\n") return

CROSS JOIN