Sql Server Inner Join with Like子句

时间:2017-06-27 04:39:07

标签: sql-server-2008

with temp as(select top 5 * from tblJobs) -- **select data from tblJobs**
select a.FirstName,a.LastName,a.Email ,b.City,a.Latitude,a.Longtitude 
from tbljobSeeker as a --select data from tblJobSeeker

inner join tblCity as b on( b.CityID = a.CityID) -- **inner join for CityName **
inner join temp as d on d.Latitude like CONCAT('%',a.Latitude,'%' ) 
and d.Longtitude like CONCAT('%',a.Longtitude,'%') 
-- ** inner join for top 5 jobs with basis of Latitude & Longtitude **
where CAST(a.Latitude AS DECIMAL(9,2))  BETWEEN CAST(d.Latitude AS  DECIMAL(9,2))-0.10 AND CAST(d.Latitude AS DECIMAL(9,2))+0.10

and CAST(a.Longtitude AS DECIMAL(9,2)) BETWEEN CAST(d.Longtitude AS DECIMAL(9,2))-0.10 AND CAST(d.Longtitude AS DECIMAL(9,2))+0.10
and a.IsDelete = 0

我有一份工作表,其中有13个工作,我有另一个工作表求职者。 我想要求职者的电子邮件列结果。两个表的常用参数是 Latitude& varchar 中的Longtitude ,但我得到了空集,查询中出现了错误

tblJobSeeker数据

ID  JobSeekerCode FirstName LastName Email          Latitude             Longutude
1   JS0001        Someone   Example abc@xyz.com   22.494636249263564 88.37204933166504  
2   JS0002        Someone1  Example1 abc1@xyz.com 19.11986822166177  73.0070686340332   
3   JS0003        Someone2  Example2 abc2@xyz.com 19.20447041013782  72.8207581040624

TABLE tbljobs 
ID  JOBCODE EmployerCode     Latitude           Longutude
1   JOB0001 EMP0018         19.08580444766317   72.8364372253418    
2   JOB0002 EMP0008         28.7041             77.30435371398926       
3   JOB0003 EMP0022         19.162519142081003  72.83819675445557   
7   JOB0006 EMP0001         19.06917553583066   72.83819675445557       
8   JOB0007 EMP0001         19.130248167229208  72.84673690795898       

0 个答案:

没有答案