What's the error in this MySQL Syntax?

Discussion in 'Plugin Development' started by RROD, Jan 15, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    RROD

    Code:
    INSERT INTO `blockplaced` (player, blockid, amount) VALUES(`RROD`, `1`, `10`) ON DUPLICATE KEY UPDATE;
    I get this:
    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 '' at line 1.

    Very useful description, MySQL!

    Does anyone have any idea what the issue is?
     
  2. Offline

    hatstand

    Have you tried it without the table name in quotes?
     
  3. i think for values you don't use `, you should use '.
    also i would recommend not using ' for integer values.
    so:
    Code:
    INSERT INTO `blocksplaced`(player, blocked, amount) VALUES('RROD', 1, 10) ON DUPLICATE KEY UPDATE
     
  4. Offline

    hatstand

    No, using ` is fine, and the quotes around the numbers should be as well, but they aren't necessary.
     
  5. Offline

    RROD

    Yes I tried the table name without quotes initially but I thought they were missing. I'll try to remove the int quotes and see how that goes.
     
  6. sure, you can use them but you can simply leave them away.
    Just looked at the mysql-reference. no ' for numbers and ' for strings ;)
     
  7. Offline

    RROD

    It's ok I figured it out. I wasn't specifiying what I want to update the value to. :D
     
Thread Status:
Not open for further replies.

Share This Page