Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this is probably a very easy one bu

Status
Not open for further replies.

CompGirl

Technical User
Jun 2, 2003
40
0
0
SE
this is probably a very easy one but i just started today with sql programming.. the thing i wanted to ask is how to set the same values in a column with one simple command...

for example

name grade
anna 5
donna 5
albert 5

in this example... if i know that they all have five and they are the only ones in my db... can i just use one sql command do write 5 to all of them??
 
Use the set command

i.e. update <table>
set grade = 5


Damian.
 
You can also add the WHERE command if you only need to update some.

Let's say you have 5 people and you only need to update those 3.

update <table>
set grade = 5
where [name] in ('anna', 'donna', 'albert')

BTW-you should NOT used reserved words for table or column names. If you do, you need to enclose them in square brackets [] or single quotes ' '.

-SQLBill
 
that was my next issue... thx for the tip ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top