Insert Statement Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daniyalnawaz
    New Member
    • Aug 2007
    • 15

    #1

    Insert Statement Problem

    Hi guys!

    Whats wrong with this statement

    [CODE=mysql]INSERT INTO MarketData(symb ol,date,time,tr ade_price,chang e)VALUES('A','2 007-09-27',16:00:00,36 .12,'0.00')[/CODE]

    im getting a following error
    #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 'change)VALUES( 'A','2007-09-27','16:00:00', 36.12,'0.00')' at line 1


    My table structure is:
    [CODE=mysql]CREATE TABLE `MarketData` (
    `MarketData_ID` int(10) unsigned NOT NULL auto_increment,
    `symbol` varchar(6) NOT NULL default '',
    `date` date NOT NULL default '0000-00-00',
    `time` time default NULL,
    `trade_price` decimal(8,2) default NULL,
    `change` varchar(10) default NULL,
    PRIMARY KEY (`MarketData_ID `)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT= 1 ;[/CODE]
    Last edited by mwasif; Sep 28 '07, 01:35 PM. Reason: Added code tags.
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Change is a reserve word in MySQL and you need to use backtick around that column name. And use quotes around time value.
    [CODE=mysql]INSERT INTO MarketData(symb ol,date,time,tr ade_price,`chan ge`) VALUES('A','200 7-09-27','16:00:00', 36.12,'0.00')[/CODE]

    Comment

    • mwasif
      Recognized Expert Contributor
      • Jul 2006
      • 802

      #3
      Moved to MySQL Forum.

      Comment

      • daniyalnawaz
        New Member
        • Aug 2007
        • 15

        #4
        Thank You!!! Its working now.... :)

        Comment

        • mwasif
          Recognized Expert Contributor
          • Jul 2006
          • 802

          #5
          You are welcome, post back whenever you need help.

          Comment

          Working...