目前,我正在建立一个招聘平台.雇主可以发布工作并接收申请.雇主可以设置求职者必须匹配的许多技能要求.求职者还可以增加他们拥有的许多技能.
我想找出的是,每个求职者技能中有多少与每个工作的owner_requirements相匹配,以便在视图中显示百分位数匹配.理想情况下,我想根据基于jobseeker_skills表和loyer_requirements表中的skill_string查找匹配项
这是3个表中每个表的数据库排列:
应用范围:
id | job_string | jobseeker_string |雇主字符串| application_string |创建日期
雇主要求:
id | skill_name | required_level | skill_string | job_string |雇主字符串|创建日期
jobseeker_skills:
id | skill_name |级别| jobseeker_string | skill_string |字符串创建日期
我有以下代码,它基于传递的’$job_str’获取所有应用程序.下面的代码只是一个简单的获取,但不确定从这里出发.
function skills_match($job_str){
$this->db->select('*')
->from('applications')
->where('job_string', $job_str)
->join('users', 'users.string = applications.jobseeker_string', 'left');
$applications = $this->db->get();
return $applications;
}
应用表-样本数据:
——– —————— —————— —— ————
| id | job_string | jobseeker_string |雇主字符串|
——– —————— —————— —— ————
| 1 | vs71FVTBb12DdGlf | uMIsuDJaBuDmo8iq | biQxyPekn6iayIgm |
| 2 | vs71FVTBb12DdGlf | x7phHsVnwJ1K1yHy | biQxyPekn6iayIgm |
| 3 | vs71FVTBb12DdGlf | Fm1TIJLxz6Xg6QPk | biQxyPekn6iayIgm |
——– —————— —— —– ——— —- ——–
雇主要求-样本数据:
——– —————— ————- ———– ——- ——————
| id | job_string | skill_name | skill_string |雇主字符串|
——– —————— ————- ———– ——- —————– |
| 1 | vs71FVTBb12DdGlf | PHP | 9Y8XeCWqJXzkZ5dD | biQxyPekn6iayIgm |
| 2 | vs71FVTBb12DdGlf | JavaScript | O6es19t5CgcRHvct | biQxyPekn6iayIgm |
| 3 | vs71FVTBb12DdGlf | HTML | wx4evsXC62BWiN7p | biQxyPekn6iayIgm |
| 4 | vs71FVTBb12DdGlf | Python | jx15rH1vrGLmsVmq | biQxyPekn6iayIgm |
| 5 | vs71FVTBb12DdGlf | SQL | EksP7mEip0Hs4zKd | biQxyPekn6iayIgm |
| 6 | vs71FVTBb12DdGlf | LESS | fj40m4hkiuDGtbzr | biQxyPekn6iayIgm |
——– —————— ————- —— —– ——— ——- ——
求职者技能-样本数据:
——– —————— —————— —— ————
| id | jobseeker_string | skill_name | skill_string |
——– —————— —————— —— ————
| 1 | uMIsuDJaBuDmo8iq | PHP | 9Y8XeCWqJXzkZ5dD |
| 2 | uMIsuDJaBuDmo8iq |骨干| 4VIiAxZoL1VbPnTa |
| 3 | x7phHsVnwJ1K1yHy |较少| fj40m4hkiuDGtbzr |
| 2 | x7phHsVnwJ1K1yHy |ruby| gTZg4fwYuzMMFcBw |
| 3 | x7phHsVnwJ1K1yHy | SQL | EksP7mEip0Hs4zKd |
| 1 | Fm1TIJLxz6Xg6QPk | PHP | 9Y8XeCWqJXzkZ5dD |
| 2 | Fm1TIJLxz6Xg6QPk | Python | jx15rH1vrGLmsVmq |
| 3 | Fm1TIJLxz6Xg6QPk | HTML | wx4evsXC62BWiN7p |
| 3 | Fm1TIJLxz6Xg6QPk | Git | aR9B9ns1sHlGrzFw |
——– —————— —— —– ——— —- ——–
基于以上内容,这应该输出百分比或否.匹配技能:
应用程序-以下是每种应用程序匹配技能的数量/百分比:
uMIsuDJaBuDmo8iq-1/6(16.666%)
x7phHsVnwJ1K1yHy-2/6(33.333%)
Fm1TIJLxz6Xg6QPk-3/6(50%)
如有任何疑问,请开除.感谢您的帮助.
解决方法:
首先,这是两个问题:
>哪些申请人最适合我的业务
>哪些雇主最适合我的技能.
这两个问题可能看起来相同,但事实并非如此.
第一个问题:
我希望所有符合我的任何要求的申请人,按照我所拥有的要求的数量排序.首先我得到所有比赛:
select *
from Requirements r
inner join Jobseeker j
on r.skill_string = j.r.skill_string
where job_string = 'vs71FVTBb12DdGlf';
然后我将em分组,计数em等:
select
jobseeker_string,
count(1) / (select count(1) from Requirements where job_string = 'vs71FVTBb12DdGlf') as match_percentage
from Requirements r
inner join Jobseeker j
on r.skill_string = j.r.skill_string
where job_string = 'vs71FVTBb12DdGlf'
group by jobseeker_string;
第二个问题:有点困难,因为申请人可能想知道他/她是否符合一定比例的工作技能,但也符合他自己的技能(这可能也适用于第一个问题).查询如下:
select
job_string,
count(1) / (select count(1) from Requirements where jobseeker_string = 'uMIsuDJaBuDmo8iq') as my_match,
count(1) / (select count(1) from Requirements where job_string = r.job_string) as job_match
from Requirements r
inner join Jobseeker j
on r.skill_string = j.r.skill_string
where jobseeker_string = 'uMIsuDJaBuDmo8iq'
group by job_string;
请注意:查询是写在我头上的,可能包含一些错字
如果要订购,可以这样:
select * from
([[insert the above query here]]) t
order by field.
合并:
select
job_string,
jobseeker_string
count(1) / (select count(1) from Requirements where jobseeker_string = r.jobseeker_string ) as seeker_match,
count(1) / (select count(1) from Requirements where job_string = r.job_string) as job_match
from Requirements r
inner join Jobseeker j
on r.skill_string = j.r.skill_string
group by job_string, jobseeker_string;
应用程序
select * from
(select
job_string,
jobseeker_string
count(1) / (select count(1) from Requirements where jobseeker_string = r.jobseeker_string ) as seeker_match,
count(1) / (select count(1) from Requirements where job_string = r.job_string) as job_match
from Requirements r
inner join Jobseeker j
on r.skill_string = j.r.skill_string
group by job_string, jobseeker_string) t
inner join applications a
on t.job_string = a.job_string and t.jobseeker_string = a.t.jobseeker_string