0

I understand how to make portfolio now, but I highly suspect (and by that I mean I know) that my SQL statement is very off. I'm not exactly sure where the "" need to go, or how to add the new amount of shares to the existing amount if the user and stock table already exist. Here is my on duplicate line, any help would be great

db.execute(IF ON DUPLICATE user_id, stock "UPDATE shares WHERE shares = shares += shares", user_id=session["user_id"], stock=stock["symbol"], shares=shared)
1
INSERT .... ON DUPLICATE KEY UPDATE....

ON DUPLICATE is a clause attached to an insert statement.

For more, google "ON DUPLICATE KEY in sql"

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

| improve this answer | |
  • So on duplicate is more of a conditional? I tell it what to do, and then if its duplicate, update instead of the first part – Joel Banks Nov 17 '18 at 23:33
  • that's the idea. – Cliff B Nov 17 '18 at 23:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .