I am trying to run a query that updates a SQL Server table (Table A) value in column 3 only on the include condition that is present in Table B and in column 2 (pref) of Table A
The primary key on both tables is Employee_number
.
And the condition in Table B active or inactive
Select Distinct employee_number
from dbo.tableB
where employee_number not in (select distinct employee_number
from dbo.tableA
where pref Pref = 'work')
and active_or_inactive = 'a'
Update TableA
Set value = “good”
Where employee_number from dbo.tableB
where employee_number not in (employee_number
from do.tableA
where Pref = 'work')
and active_or_inactive = 'a'
1条答案
按热度按时间nkhmeac61#
It's not entirely clear how everything fits together in the sample code, but try this: