我目前正在获得预期的输出,但我现在希望按skill_match
订购查询,但不确定如何按skill_match
订购当前查询。 skill_match
存在于嵌套查询中。
我的问题是我如何按skill_match
$matches = $this->db->query("
SELECT *
FROM
(SELECT job_string, jobseeker_string, requirement_type,
count(1) / (SELECT count(1) FROM employer_requirements WHERE jobseeker_string = j.jobseeker_string AND requirement_type = 'e' ) AS skill_match
FROM employer_requirements r
INNER JOIN jobseeker_skills j
ON r.skill_string = j.skill_string
GROUP BY job_string, jobseeker_string) t
LEFT JOIN users u
ON t.jobseeker_string = u.string
INNER JOIN applications a
on t.job_string = a.job_string and t.jobseeker_string = a.jobseeker_string
WHERE a.job_string = '".$str."'
ORDER_BY r.skill_match
");
return $matches;
当我执行print_r()
并想要ORDER_BY skill_match
值时,我得到以下输出:
Array
(
[0] => Array
(
[job_string] => G2vJhXNUquRELfxQ
[jobseeker_string] => ltyjBhtbHn5knsht
[requirement_type] => e
[skill_match] => 0.2000
[id] => 1
[user_level] => 3
[name] => Steve
[email] => something@hotmail.com
[password] => 3b8751e0f3f81ea085329e44d1d28f2e105f4031efd02ff7430c05d88ce90dcbacaef2f4239882e784b3d133d8aadc88404e670b284b95ab6963b58d00a6b864
[score] => 116
[string] => ltyjBhtbHn5knsht
[date_created] => 2014-04-15 12:16:13
[employer_string] => sm4jBhtbv13knsht
[application_string] => bX0JOwUnhsKEQaAq
)
[1] => Array
(
[job_string] => G2vJhXNUquRELfxQ
[jobseeker_string] => qThkM0OIKVUukp6J
[requirement_type] => e
[skill_match] => 0.4000
[id] => 2
[user_level] => 3
[name] => Bruce
[email] => someone@gmail.com
[password] => 3b8751e0f3f81ea085329e44d1d28f2e105f4031efd02ff7430c05d88ce90dcbacaef2f4239882e784b3d133d8aadc88404e670b284b95ab6963b58d00a6b864
[score] => 116
[string] => qThkM0OIKVUukp6J
[date_created] => 2014-04-15 12:16:13
[employer_string] => sm4jBhtbv13knsht
[application_string] => bX0JOwUnhsKEQaAq
)
)
我感谢任何帮助。
答案 0 :(得分:2)
我认为它不应该是ORDER_BY r.skill_match
,而应该是ORDER BY t.skill_match
。
答案 1 :(得分:1)
ORDER BY没有下划线(_)
$matches = $this->db->query("
SELECT *
FROM
(SELECT job_string, jobseeker_string, requirement_type,
count(1) / (SELECT count(1) FROM employer_requirements WHERE jobseeker_string = j.jobseeker_string AND requirement_type = 'e' ) AS skill_match
FROM employer_requirements r
INNER JOIN jobseeker_skills j
ON r.skill_string = j.skill_string
GROUP BY job_string, jobseeker_string) t
LEFT JOIN users u
ON t.jobseeker_string = u.string
INNER JOIN applications a
on t.job_string = a.job_string and t.jobseeker_string = a.jobseeker_string
WHERE a.job_string = '".$str."'
ORDER BY r.skill_match
");
return $matches;