# Database Discussions > Microsoft SQL Server 2005 >  To replace selected records in a field based on condition of another field

## nijojo

Hi,

Please can anyone provide an SQL syntax: 

To replace selected records in a field based on condition of another field. For example, 
Two fields a and b. 'a' field has three records, 1,2,3. b field has x,y and z. I like to replace all records '2' in field a if 
field b is x with value 5

Thanks.
Nijojo.

----------


## rmiao

Are they in same table? If so, try this:

update table set a = 5 where a = 2 and b = 'x'

----------

