insert statement

  • Thread starter enrico via AccessMonster.com
  • Start date
E

enrico via AccessMonster.com

how do you put a condition on your INSERT statement? e.g. INSERT INTO "table"
(data) VALUES ("entry") WHERE...

every time i used my sample above it always gives an error that a semicolon
is missing at the end of the SQL statement.
 
J

John W. Vinson

how do you put a condition on your INSERT statement? e.g. INSERT INTO "table"
(data) VALUES ("entry") WHERE...

every time i used my sample above it always gives an error that a semicolon
is missing at the end of the SQL statement.

You can't put a WHERE statement on an insert with a VALUES clause: the
Values() operand specifies the fields for *a single record* which is to be
inserted. It just adds a new record to the table so there is no filtering or
selection to be done.

If you want to insert multiple records from TableA into TableB you would use
the SELECT version:

INSERT INTO TableA([thisfield], [thatfield], [theotherfield])
SELECT this, that, theother FROM TableB
WHERE <some conditions>;

If you're trying to insert data into an EXISTING record, you would not use an
Insert query but rather an Update query.

Perhaps you could explain the context, and what you're trying to accomplish,
and what you're starting with.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top