Skip to content
Advertisement

SQL Insert Into Where

INSERT INTO Participant (Password) 
VALUES ('768YcnaDG') 
WHERE ParticipantID = 1048

I’m trying to do an insert into SQL command with a where clause. There is an error message that says incorrect syntax near where. How would I go about fixing this?

Advertisement

Answer

Presumably, you want UPDATE, not INSERT:

UPDATE Participant 
    SET Password = '768YcnaDG'
    WHERE ParticipantID = 1048;

INSERT adds an entirely new row into the table. UPDATE modifies the values of one or more columns.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement