Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    63

    Unanswered: Syntax error for insert

    Hi All,

    What's wrong with the following SQL:

    INSERT INTO user_info ( ID, Title, Notes ) VALUES ( SELECT ID, Title, Notes FROM user WHERE ID = 129)

    Error:
    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT ID, Title, Notes FROM user WHERE ID = 129)' at line 2

    user and user_info have a one-to-one relationship (innodb/myisam) for full-text searchability.

    TIA

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    INSERT INTO user_info ( ID, Title, Notes )
    SELECT ID, Title, Notes
    FROM user WHERE ID = 129;

    The VALUES is not needed when using a SELECT

  3. #3
    Join Date
    Jul 2005
    Posts
    63
    It worked!!

    Thanks much!

  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Btw: next time simply read the manual
    http://dev.mysql.com/doc/refman/5.0/en/insert.html

Posting Permissions

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