Is there a way to do something like insert into…where in mysql node.js

0

Issue

I am using postman to test my api and this is a post request.

when i put the request url in postman it should say
http://localhost:3000/product/1/food/
with the 1 being :id in my code

I want to execute this sql statement in my node.js

INSERT INTO food (userid, rating, fooditem) VALUES (?, ?, ?) WHERE productid=?' 

productid is my :id

to get my table to show
enter image description here

the foodid and timestamps are auto incremented

but it gives me

ER_PARSE_ERROR

I have tried using

UPDATE food
SET userid=? , rating=? , review=?
WHERE productid=?
            

based off other posts I have found here, however nothing pops up in my table when i do this although it is not counted as an error in my code

What should I do?
thank you

Solution

you don’t use WHERE to specify the productid column, it should just be another column that you insert into.

INSERT INTO food (userid, rating, fooditem, productid) VALUES (?, ?, ?, ?)

Answered By – Barmar

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More