Ian Vink
Ian Vink

Reputation: 68750

Updating database row for a group of people

Newbie. SQL Server 2014

I am trying to update a flag, but am unsure of the structure. Here's a simplified snip of what I am doing

update tblCustomer 
set IsHappy=true 
where country=1 and 
firstname in (ian,bob,sam,joe)

Any ideas how to do this in one line?

Upvotes: 0

Views: 42

Answers (1)

marc_s
marc_s

Reputation: 754358

First of all, put your string literals in single quotes, and T-SQL doesn't know "true" or "false" - it's 1 (for true) or 0 (for false) for a BIT column.

update tblCustomer 
set IsHappy = 1 
where country = 1 
  and firstname in ('ian', 'bob', 'sam', 'joe')

Upvotes: 4

Related Questions