Create employee list which not exist in first select

Hi All.
In GataGrid1 of employees populated by selected ComboBox department value. Now I would like to populate DataGrid2 list of all other employees except employees that not displayed in Form1. How to create select for DatGrid2?
Thanks.

hi

this is a microsoft t-sql forum ..

Hi harishgg1. Thanks for reply.
In the first post I described where I plan to use select that asked. My question exactly about t-sql. I'm asking how create select to except records that is not selected before.
Thanks.

hi

in SQL this is a very very simple to do !!

-- My thoughts ..
i have to understand what you mean by ???
---- I'm asking how create select to except records that is not selected before.

if you selected before .. you have to know or mark which ones you selected before

then in your SQL
select records from table where something not in ( the records you selected before )
once you do this select .. again you mark these records as selected before !!

Hi.
Do you have a sample? Thanks.

hi

hope this helps :+1:

drop table sample_data
go 

create table sample_data 
(
id int , 
age int 
)
go 

insert into sample_data select 1,40 
insert into sample_data select 2,23 
insert into sample_data select 3,35 
go 

select ' Sample Data ' , * from sample_data
go 

drop table Table_Search_data 
go 

create table Table_Search_data 
(
id int 
)

insert into Table_Search_data select 1
insert into Table_Search_data select 4 
go 

select 'Table_Search_data ' , * from Table_Search_data 
   * 
from 
  Table_Search_data 
where 
  id not in 
    ( select id from sample_data ) 

image
image
image

Thanks a lot