如何更改SQL中某列的值
发布网友
发布时间:2022-05-01 16:46
我来回答
共5个回答
热心网友
时间:2022-04-10 01:02
通过update方法实现。
sql:update table tablename t set filename =值1 where t.name='条件'。
解释:更改某列,说明有条件,所有必须通过“where”条件语句定位到列。定位成功后,通过set方法给固定字段赋值即可。
上面sql语句的意思:更改tablename 表中name值为“条件”的记录,将“filename ”的值改为“值1”。
热心网友
时间:2022-04-10 02:20
不明白你的意思?是更改 从数据库中取出后的值呢,还是更改数据库中的值。更改数据库的值 用 update 语句,更改取出后的值呢,就不用说了吧。
热心网友
时间:2022-04-10 03:55
建议你看看sqlserver的联机帮助,里面讲的很详细
UPDATE
更改表中的现有数据。
语法
UPDATE
{
table_name WITH ( < table_hint_limited > [ ...n ] )
| view_name
| rowset_function_limited
}
SET
{ column_name = { expression | DEFAULT | NULL }
| @variable = expression
| @variable = column = expression } [ ,...n ]
{ { [ FROM { < table_source > } [ ,...n ] ]
[ WHERE
< search_condition > ] }
|
[ WHERE CURRENT OF
{ { [ GLOBAL ] cursor_name } | cursor_variable_name }
] }
[ OPTION ( < query_hint > [ ,...n ] ) ]
< table_source > ::=
table_name [ [ AS ] table_alias ] [ WITH ( < table_hint > [ ,...n ] ) ]
| view_name [ [ AS ] table_alias ]
| rowset_function [ [ AS ] table_alias ]
| derived_table [ AS ] table_alias [ ( column_alias [ ,...n ] ) ]
| < joined_table >
< joined_table > ::=
< table_source > < join_type > < table_source > ON < search_condition >
| < table_source > CROSS JOIN < table_source >
| < joined_table >
< join_type > ::=
[ INNER | { { LEFT | RIGHT | FULL } [OUTER] } ]
[ < join_hint > ]
JOIN
< table_hint_limited > ::=
{ FASTFIRSTROW
| HOLDLOCK
| PAGLOCK
| READCOMMITTED
| REPEATABLEREAD
| ROWLOCK
| SERIALIZABLE
| TABLOCK
| TABLOCKX
| UPDLOCK
}
< table_hint > ::=
{ INDEX ( index_val [ ,...n ] )
| FASTFIRSTROW
| HOLDLOCK
| NOLOCK
| PAGLOCK
| READCOMMITTED
| READPAST
| READUNCOMMITTED
| REPEATABLEREAD
| ROWLOCK
| SERIALIZABLE
| TABLOCK
| TABLOCKX
| UPDLOCK
}
< query_hint > ::=
{ { HASH | ORDER } GROUP
| { CONCAT | HASH | MERGE } UNION
| {LOOP | MERGE | HASH } JOIN
| FAST number_rows
| FORCE ORDER
| MAXDOP
| ROBUST PLAN
| KEEP PLAN
}
例如:
UPDATE authors
SET state = 'ZZ'
FROM (SELECT TOP 10 * FROM authors ORDER BY au_lname) AS t1
WHERE authors.au_id = t1.au_id
热心网友
时间:2022-04-10 05:46
你用update table set 字段=“” where id =“id”就可以了
热心网友
时间:2022-04-10 07:54
rs("friend") = "值";