如何使所有没有条件的Maps_Pos表中没有记录的医生有条件? [英] How to get all doctor that has no record in Maps_Pos table with condition ?

查看:113
本文介绍了如何使所有没有条件的Maps_Pos表中没有记录的医生有条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有3张桌子:

1.医生:>> DoctorID,DoctorName.

2. AreaDoctors:>> ID,AreaID,DoctorID

3. Maps_Pos:>> ID,DoctorID,IDFromAreaDoctor,Pos_latitude,Pos_longitude

现在,我尝试从同一时间(不在表Maps_Pos中)(表AreaDoctors)中存在DoctorID的(医生表)中获取所有医生


Hi

i have 3 tables:

1. Doctors: >> DoctorID, DoctorName.

2. AreaDoctors: >> ID, AreaID, DoctorID

3. Maps_Pos: >> ID, DoctorID, IDFromAreaDoctor, Pos_latitude, Pos_longitude

Now, i try to get all doctors from (doctor table) where DoctorID is in (table AreaDoctors) and in same time (not in table Maps_Pos)


var allDoctorsInArea = db.Doctors.Where(i=>i.AreaDoctors.Where(j=>j.AreaID==userInformations.AreaID).Count()>0 && i.Maps_Pos.Count()==0).
.Select(i => new { i.DoctorID, i.DoctorName })
.ToList();


它工作正常,但是在areadoctor医生中有很多记录,例如很多区域:


it works fine, but in areadoctor doctor has many record with many area as example:

id       doctorid        areaid      ect ...

1           1              200 // this in Maps_pos (don't get it)

2           1              205 // this in Maps_pos (dont get it)

3           1              203  // user has this area (203) but i need to get doctorid (1) in this area only because it's don't saved in "Maps_pos"

4           2              300 // this in Maps_pos

ect .......


和Maps_Pos表:


and Maps_Pos table:

id       doctorid        IDFromAreaDoctor                                              pos1         pos2    ect ...

1           1                   1    // here 1 is the id of record in areadoctor table  ..            .. 

2           1                   2    // here 2 is the id of record in areadoctor table  ..            .. 

3           2                   4              ..      ..

ect .......


在我的示例中,我需要获取在maps_pos中没有任何区域记录的所有医生,我必须提供Doctorid = 1的数据,因为他已经退缩了,而在maps_pos中(此处ID = 3)
所以,请问我该如何抛出上面的代码?


i need to get all doctor that don''t has any area record in maps_pos in my example i must data for doctorid = 1 because he have recede are not in maps_pos yet (here ID is = 3)

so please how can i do it throw my above code ?

推荐答案

现在,我尝试从DoctorID所在的(医生表)中获取所有医生(表AreaDoctors)和同一时间(不在表Maps_Pos中)

从医生中选择*
哪里是Doctorid IN(请从Areadoctors中选择Doctorid
和Doctorid NOT IN(从Maps_pos
中选择Doctorid
像这样的东西
Now, i try to get all doctors from (doctor table) where DoctorID is in (table AreaDoctors) and in same time (not in table Maps_Pos)

Select * from Doctors
where doctorid IN (select doctorid from Areadoctors
and doctorid NOT IN (select doctorid from Maps_pos

something like that


这篇关于如何使所有没有条件的Maps_Pos表中没有记录的医生有条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆