在mysql中更新需要很好的声明

时间:2012-05-16 09:23:10

标签: mysql sql

我是sql中的新手。我正在根据数据进行查询

如何编写查询以更新行;我想要遵循这种格式;

UPDATE `reports_attributes` 
  (`ConID`,`CheckServices`,`Attribute1`,`Attribute2`,`Attribute3`,`Attribute4`,`Attribute5`,`Attribute6`,`Attribute7`,`Attribute8`) 
VALUES ('78','Execute Summary','criminality','color1','education','color5','employment_check_2','color7','report_status','color9')  
WHERE ConID=78 AND ReportType='interim_report' 

4 个答案:

答案 0 :(得分:2)

Update Statement语法与Insert。

不同
UPDATE reports_attributes 
 Set 
 ConID='78',
 CheckServices='Execute Summary',
 Attribute1='criminality',
 Attribute2='color1',
 Attribute3='education',
 Attribute4='color5',
 Attribute5='employment_check_2',
 Attribute6='color7',
 Attribute7='report_status',
 Attribute8='color9'
WHERE ConID=78 AND ReportType='interim_report'  

答案 1 :(得分:1)

UPDATE语句的语法是

UPDATE reports_attributes
    SET ConID = 78,
        CheckServices = xxx, 
        .
        .
        n
WHERE ConID=78 AND ReportType='interim_report' 

答案 2 :(得分:1)

问题中的语法与syntax of an update statement

不匹配
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
    SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

有效更新语句的示例是:

UPDATE mytable
SET
    foo = "bar"
WHERE
    id = 123

答案 3 :(得分:1)

UPDATE reports_attributes 
SET ConID='78', 
    CheckServices='Execute Summary' ,
    Attribute1='criminality', 
    Attribute2='color1', 
    Attribute3='education', 
    Attribute4='color5',
    Attribute5='employment_check_2',
    Attribute6='color7', 
    Attribute7='report_status', 
    Attribute8='color9' 
WHERE ConID=78 
      AND ReportType='interim_report'