Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2004
    Location
    Paris, FRANCE
    Posts
    132

    Unanswered: Insert ... Set -> Ansi ?

    Hello.
    The question is in the title.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the answer is "maybe"
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2004
    Location
    Paris, FRANCE
    Posts
    132
    Maybe ?

    Can I do

    Code:
    INSERT table
    SET
    key1 = value1
    key2 = value1
    .
    .
    with ANSI92 compliant DB ?

  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    That would be the syntax for UPDATE:
    Code:
    UPDATE theTable SET key1 = value1, key2 = value2
    WHERE ...
    For INSERT you will need the following syntax:
    Code:
    INSERT INTO theTable 
    (key1, key2) 
    VALUES
    (value1, value2);
    Details in the manual for insert and for update.

    The question is: do you want to create a new row, or change (update) an existing one?

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i think gtk just wants to INSERT

    i'm guessing the previous experience was mysql

    INSERT SET syntax is non-standard, mysql-proprietary
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Oct 2004
    Location
    Paris, FRANCE
    Posts
    132
    Ok thank you Rudy, you are right.
    Now I wonder why don't they implement this syntax.
    It seems to me to be slightly more maintainable, simple
    and compatible with UPDATE for single row INSERTs.

  7. #7
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Well, the question is rather: why on earth did MySQL choose to implement a completely new and in-compatible syntax if there is already a well defined standard for this?

  8. #8
    Join Date
    Oct 2004
    Location
    Paris, FRANCE
    Posts
    132
    For the INSERT, MySQL have implemented both syntaxes since quite a long time.
    And I don't think that their aim is to manage a new syntax before the standard.

Posting Permissions

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