1

I want to insert two dates into a specifc row on my table using MySql but have a syntax error on Workbench (Error 1064):

INSERT INTO atable (Activated,Expiry) WHERE Access_Code = 'accesscode'
VALUES('$current_date','$Expiration_Date') 

What would be the correct version for this?

2
  • 1
    INSERT statements don't have a WHERE clause. The point of a WHERE clause is to filter existing rows but INSERT statements don't affect existing rows. Do you want to insert a new row or do you actually want to update an existing row? If it's the latter then you use an UPDATE statement. Commented Jul 23, 2014 at 0:31
  • I understand. This is embarrassing. Update it is Commented Jul 23, 2014 at 0:31

1 Answer 1

1

It would be something like this:

UPDATE atable
SET Activated='$current_date',
    Expiry='$Expiration_date'
WHERE Access_Code='accesscode';

I'm assuming you will be setting $current_date and $Expiration_date via (what looks like PHP) code.

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.