Results 1 to 3 of 3
  1. #1
    FinalByte is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2013
    Posts
    1

    Angry Insert value and select ID

    I have this query, but don't work....

    INSERT INTO Tests (Name) VALUES ('aaaaaa') SELECT ID FROM Tests WHERE Name='aaaaaa';

    My table is:
    | ID | Name |
    | 1 | Test111 |
    | 2 | Test222 |
    | 3 | Test333 |
    | 4 | Test444 |



    I want insert value 'aaaaaa' and I want select ID only in one query....

    Can you help????

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Here is the insert syntax from http://msdn.microsoft.com/en-us/libr.../ff834799.aspx

    INSERT INTO target [(field1[, field2[, …]])] [IN externaldatabase] SELECT [source.]field1[, field2[, …] FROM tableexpression

    or

    INSERT INTO target [(field1[, field2[, …]])] VALUES (value1[, value2[, …])


    Hope this helps.

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    Since you identify yourself as a novice; my recommendation is to not use sql code but instead to review/research the instructions for an UPDATE query type available through the query design view.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How do I Insert Values w/ Not Exists sub select?
    By toddbailey in forum Queries
    Replies: 1
    Last Post: 05-01-2012, 12:05 PM
  2. INSERT with SELECT query.
    By goodguy in forum Queries
    Replies: 8
    Last Post: 09-23-2011, 10:38 AM
  3. select and insert using two seperate tables
    By benjammin in forum Queries
    Replies: 2
    Last Post: 02-20-2011, 04:52 PM
  4. INSERT INTO ... SELECT Subquery
    By TheDeceived in forum Programming
    Replies: 1
    Last Post: 10-19-2010, 09:29 AM
  5. Replies: 0
    Last Post: 09-08-2009, 11:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums