首頁 >後端開發 >php教程 >php update数据更新简单实例_PHP教程

php update数据更新简单实例_PHP教程

WBOY
WBOY原創
2016-07-13 17:05:501122瀏覽

sql update记录更新详细实例

语法:

[ WITH [...n] ]
UPDATE
    [ TOP (expression) [ PERCENT ] ]
    { { table_alias | | rowset_function_limited
         [ WITH ( [ ...n ] ) ]
      }
      | @table_variable   
    }
    SET
        { column_name= { expression | DEFAULT | NULL }
          | { udt_column_name.{ { property_name= expression
                                | field_name=expression }
                                | method_name(argument [ ,...n ] )
                              }
            }
          | column_name { .WRITE (expression,@Offset,@Length) }
          | @variable=expression
          | @variable= column=expression
          | column_name { += | -= | *= | /= | %= | &= | ^= | |= } expression
          | @variable { += | -= | *= | /= | %= | &= | ^= | |= } expression
          | @variable=column { += | -= | *= | /= | %= | &= | ^= | |= } expression
        } [ ,...n ]

    [ ]
    [ FROM { } [ ,...n ] ]
    [ WHERE {
            | { [ CURRENT OF
                  { { [ GLOBAL ] cursor_name }
                      | cursor_variable_name
                  }
                ]
              }
            }
    ]
    [ OPTION ( [ ,...n ] ) ]
[ ; ]

::=
{
    [ server_name . database_name . schema_name .
    | database_name .[ schema_name ] .
    | schema_name .
    ]
    table_or_view_name}

实例 php教程

   mysql教程_connect("mysql153.secureserver.net","java2s","password");
   mysql_select_db("java2s");

   $query = "UPDATE Employee SET salary = '39.99' ";
   $result = mysql_query($query);
   echo "There were ".mysql_affected_rows()." product(s) affected. ";

?>


利用update 更新数据

   mysql_connect("mysql153.secureserver.net","java2s","password");
   mysql_select_db("java2s");

   $rowID = "0001";
   $name = "Kate";
   $price = "12";

      $query = "UPDATE Employee SET name='$name', price='$price' WHERE ID='$rowID'";
      $result = mysql_query($query);

      if ($result)
         echo "

The developer has been successfully updated.

";
      else
         echo "

There was a problem updating the developer.

";

 

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630745.htmlTechArticlesql update记录更新详细实例 语法: [ WITH common_table_expression [...n] ] UPDATE [ TOP (expression) [ PERCENT ] ] { { table_alias | object | rowset_function_limited [ WITH...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn