1

Hi I am very new to this and using Access I am attempting to insert into table EMPLOYEE a column called MIDDLENAME and for one employee-id a value called Junior what have I done wrong here - I get "Syntax error on INSERT INTO command"

INSERT INTO EMPLOYEE
(MIDDLENAME)
VALUES
[JUNIOR]
(WHERE EMPLOYEE_ID IS 'E9876543)';
5
  • what has join tag have to do? what exactly do u mean in you title? Commented Feb 11, 2014 at 20:00
  • Did you meant to UPDATE the existing record? Commented Feb 11, 2014 at 20:25
  • this combined two questions I was wanting to ask sorry it made sense the first time I posted Commented Feb 11, 2014 at 20:26
  • no join no nested query - the heading relates to different question sorry Commented Feb 11, 2014 at 20:27
  • The question isn't totally clear. Are you trying to update an existing record, or insert a new one? Commented Feb 11, 2014 at 20:29

2 Answers 2

1

EDIT: If the column doesn't yet exist you need to modify the table structure first, and then run the UPDATE below:

ALTER TABLE EMPLOYEE ADD COLUMN MIDDLENAME TEXT(25); -- or whatever length

The question isn't entirely clear to me, but it sounds like you're trying to update an existing employee by changing his middle name:

UPDATE EMPLOYEE
SET MIDDLENAME = 'JUNIOR'
WHERE EMPLOYEE_ID = 'E9876543';

You had a few syntax errors in your query:

  • EMPLOYEE_ID IS 'E9876543) ... use = and not IS
  • () around your WHERE clause
  • Probably a misplaced ) in your string literal ... 'E9876543)'

Also, be careful about how you use the terms insert and update when it comes to database queries.

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

1 Comment

Im adding a currently non existent column called Middlename
-1

INSERT INTO EMPLOYEE (MIDDLENAME) VALUES ('JUNIOR') WHERE EMPLOYEE_ID = 'E9876543';

1 Comment

now error says query input must contain table or query

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.