How to avoid Duplicate values for INSERT in SQL?

前端 未结 6 642

I have one table named:

Delegates

This table has four fields:

ID(Auto increment, Primary)
MemberNo, FromYr, ToYr
         


        
6条回答
  •  鱼传尺愫
    2020-11-27 08:05

    Try this, (I have not verified)

    INSERT INTO Delegates ([MemNo],[FromYr],[ToYr]) values(@MemNo, @FromYr,@ToYr)
    where @MemNo not in 
    (
        SELECT MemNo FROM words WHERE FromYr = @FromYr
    )
    

提交回复
热议问题