Sangam Singh
Sangam Singh

Reputation: 41

An expression of non-boolean type specified in a context where a condition is expected, near ')'. error in SQL

I need to find matching id from two tables (client & activity), and update the data from (clientid) column in table client to the same column (id) the other table (activity):

update activity
set a.clientid = r.clientid 
where (select r.clientid, r.id 
       from request r 
       where exists(select a.activityid from activity a where (a.id = r.id))

It throws an exception

An expression of non-boolean type specified in a context where a condition is expected, near ')'

Upvotes: 0

Views: 273

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1270593

I think you want an update with join. In SQL Server, this looks like:

update a
    set clientid = r.clientid 
from activity a join
     request r
     on a.id = r.id;

Upvotes: 0

Nick
Nick

Reputation: 147216

It's hard to be sure without sample data but it looks like you're looking for

UPDATE activity a
JOIN request r ON r.id = a.id
SET a.clientid = r.clientid

Upvotes: 1

Related Questions