Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First, the obvious error is syntaxis error: INSERT command does not have WHERE clause. This is the reason for the raisng error.

The second error is logical: INSERT command adds a NEW row in the table. To modify the EXSITNG row you need UPDATE command it has WHERE clause (as sad @a_horse_with_no_name)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!