SQL UPDATE查询 - 基本的东西,但看不出有什么问题?

时间:2011-07-08 02:10:14

标签: sql

我只是尝试使用SQL执行更新命令,但从未真正使用它。我目前有这样的命令:

UPDATE 'assets' SET 'SKU' = "Another",
'Quantity' = "3",
'Description' = "Another thing",
'Value' = "2100",
'Location' = "Acheroon",
'Owner' = "Fergus",
'Image' = "Nope",
'Notes' = "" WHERE 'Index' = "2" 

我尝试通过PHP层运行它,直接进入数据库。怎么了?

1 个答案:

答案 0 :(得分:4)

'替换为`,然后将"替换为'

试试这个:

UPDATE `assets` 
    SET `SKU` = 'Another',
        `Quantity` = '3',
        `Description` = 'Another thing',
        `Value` = '2100',
        `Location` = 'Acheroon',
        `Owner` = 'Fergus',
        `Image` = 'Nope',
        `Notes` = '' 
  WHERE `Index` = '2' 

UPDATE assets 
    SET SKU = 'Another',
        Quantity = '3',
        Description = 'Another thing',
        Value = '2100',
        Location = 'Acheroon',
        Owner = 'Fergus',
        Image = 'Nope',
        Notes = ''
  WHERE `Index` = '2'