Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    3

    Red face Unanswered: Acess/ SQL insert command

    I am using a database in Access and using SQL to insert data into the table. I have figured out how to insert one line of data, now want to insert two or more lines. Using the folowing syntax to insert one line:

    Insert into customer (Customer_ID, First_Name, Last_Name, Street, City, State, ZipCode, Phone)
    VALUES ('11', 'Billy', 'Joel', '600 West Central', 'NewYork', 'NY', '53434', '604-234-3434');

    Now, from what I figured out you can use the following to insert two rows:

    INSERT INTO Customer ( Customer_ID, First_Name, Last_Name, Street, City, State, ZipCode, Phone )
    VALUES ('11', 'Billy', 'Joel', '600 West Central', 'New York', 'NY', '53434', '604-234-3434'),
    ('12', 'Kelly', 'West', '954 Howard Blvd', 'Athens', 'GA', '56545', '341-341-3409');

    I get the error missing semicolon at end of sql statment. Any help please?!!!

  2. #2
    Join Date
    Aug 2003
    Location
    Bosnia & Hercegovina
    Posts
    57
    you simply can't do that. values is meant for one set of values i.e. one record....

    if you want to add more records you will have either to creat multiple sql insert statements or have data in some other table and then use INSERT / SELECT type of query...

    if you want you might create one INSERT statement with parameters and then just feed it with data by calling it from program as many times as you want.......

  3. #3
    Join Date
    Aug 2003
    Posts
    3
    That is what I though. Now...I have 4 seperate tables.
    If I am adding a record via the insert command to line 13, can I add it to the other tables at the same time, or would I have to make separate statements?

    IE:
    Insert into Customer
    Values
    ('1', '2'....)
    Insert into Invoice
    Values
    ('3', '4'....)

    the records all relate back to the customer invoice. I doubt I can do this but just need some pointing in the right direction.

    Thanks..

  4. #4
    Join Date
    Aug 2003
    Location
    Bosnia & Hercegovina
    Posts
    57
    each INSERT deals with only one table....

    you can put only one INSERT statement in one query...

    so create separate queries and run those one after another....

    if you pick up your values from form I suggest using parameters (look up parameters in access help, there are samples DAO)....

  5. #5
    Join Date
    Aug 2003
    Posts
    3
    appreciate. that is what I though, just trying to clean it up some.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •