Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2017
    Posts
    12

    Populate table with SELECT and WHERE

    Hello all.

    I'm hoping someone can help me. I've been Googling this for half an hour and gotten nowhere.

    I have a table called TempComments. Another table called Customer. What I want to do is populate the TempComments table with qualifying CustomerID's and static text. My query (which clearly doesn't work) goes like this:



    Code:
    INSERT INTO TempComments (CustomerID, CommentUser, Comments)
    SELECT (CustomerID, 'SMS', 'This is a test')
    FROM Customer WHERE CustomerID > 'ABC-123456'
    The table should then look like:
    ABC-123457 SMS This is a test
    ABC-123458 SMS This is a test
    ABC-123459 SMS This is a test
    ABC-123460 SMS This is a test
    ...

    Can anyone assist me at all?

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have parenthesis in the SELECT clause that shouldn't be there
    Code:
    INSERT INTO TempComments (CustomerID, CommentUser, Comments)
    SELECT (CustomerID, 'SMS', 'This is a test')                    '<<<--- remove parenthesis 
    FROM Customer WHERE CustomerID > 'ABC-123456'
    Try the select query first
    Code:
    SELECT CustomerID, 'SMS', 'This is a test'
    FROM Customer WHERE CustomerID > 'ABC-123456';
    This should show what records would be selected .


    Now the append query (it worked for me)
    Code:
    INSERT INTO TempComments (CustomerID, CommentUser, Comments)
    SELECT CustomerID, 'SMS', 'This is a test'
    FROM Customer WHERE CustomerID > 'ABC-123456';

  3. #3
    Join Date
    Mar 2017
    Posts
    12
    Amazing.

    Thank you for your help.

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

Similar Threads

  1. Replies: 10
    Last Post: 10-13-2016, 09:21 PM
  2. Replies: 4
    Last Post: 09-07-2016, 05:02 AM
  3. Replies: 1
    Last Post: 12-16-2013, 03:22 AM
  4. Replies: 11
    Last Post: 10-02-2013, 09:59 AM
  5. Replies: 12
    Last Post: 11-18-2012, 03:53 PM

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