Home:ALL Converter>How do i insert values into a column within a specific row in PostgreSQL?

How do i insert values into a column within a specific row in PostgreSQL?

Ask Time:2021-09-22T05:17:08         Author:Oran_Cowell

Json Formatter

I'm trying to insert table values into my postgreSQL database into a certain row but struggling, any ideas?

The code I've been using is the following but it keeps returning errors.For clarity, applicationname and applicationemail are the values and role_id is personal to the row.

I know the following code is wrong but it's the closest line i can think of achieving it.

Where am i going wrong?

    await pool2.query(
      "INSERT INTO contracts (applicationname, applicationemail) VALUES ($1, $2) WHERE role_id = $3",
      [name, email, role_id]
    );

*disclaimer, I'm recently new to coding any help would be much appreciated!

Author:Oran_Cowell,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275646/how-do-i-insert-values-into-a-column-within-a-specific-row-in-postgresql
yy