SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: SQL Error

  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    SQL Error

    Whats wrong with this SQL?
    Code:
    UPDATE gallery ( name, url, date, info )
    VALUES ( 'neo-vs-2smith_avatar.gif', 'C:\Documents and Settings\Cameron\Desktop\pictures\Matrix Avatar Set/neo-vs-2smith_avatar.gif', '', 'Neo versus a bunch of Agent Smiths' )
    WHERE id=1
    I'm using MySQL 4.1 but I got this same error before I updated. This is what MySQL is telling me
    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 '( name, url, date, info ) VALUES ( 'neo-vs-2smith_avatar.gif',
    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    mysql has proprietary extensions to standard sql, but i always use standard sql
    Code:
    UPDATE gallery 
       SET name  = 'neo-vs-2smith_avatar.gif'
         , url   = 'C:\Documents and Settings\Cameron\Desktop\pictures\Matrix Avatar Set/neo-vs-2smith_avatar.gif'
         , date  = ''
         , info  = 'Neo versus a bunch of Agent Smiths'
     WHERE id=1
    tip: don't use a reserved word (e.g. date) as the name of a column

    rudy
    http://r937.com/

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Yep, just after I posted I had a kind of brainwave and change date, but yeah, I didn't think to check the manual otherwise I would've seen to use SET for UPDATE queries, do you recommend using SET rather than VALUES for inserts as well?

    Thanks again!
    Rep coming.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    no, SET for inserts is non-standard, and i avoid non-standard syntax when standard syntax is adequate

    rudy
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Lol, very confusing

    Got any links which lists "standard" SQL syntax so I can try and stick by that?

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    i wish there were...

    one thing you could do is run your query into the Mimer SQL Validator


Bookmarks

Posting Permissions

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