multiple INSERT

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wesley@ispace.co.za

    #1

    multiple INSERT

    Can i make multiple inserts into a table using one statement.
    the statement:
    INSERT INTO table1 (UserName) VALUES (SELECT DISTINCT UserName FROM
    table2)

    Basically, i want to take out all the UserNames from table2 and insert
    them into table1.
    It doesnt work, why?
    Thanks Wes

  • Bill Karwin

    #2
    Re: multiple INSERT

    wesley@ispace.c o.za wrote:[color=blue]
    > Can i make multiple inserts into a table using one statement.
    > the statement:
    > INSERT INTO table1 (UserName) VALUES (SELECT DISTINCT UserName FROM
    > table2)[/color]

    This one trips me up from time to time. Take out the word 'VALUES'.

    Refer to syntax documented here:
    http://dev.mysql.com/doc/refman/5.0/en/insert.html

    Regards,
    Bill K.

    Comment

    Working...