人们,有人可以告诉我如何在联接中实现以下查询,与以下查询相比,该查询具有更高的性能
SELECT *, count(*) c FROM question_ans_word where answer_id in
(select answer_id from question_ans_word where keywords_id in
(SELECT id FROM uniqueword where word like "minimum")
)
group by answer_id;
答案 0 :(得分:2)
以下是如何使用联接执行此操作。我是否能说出它是否会更好:
SELECT * FROM
job
WHERE
1= (CASE WHEN jobbusiness=1 AND (jobstartdate >= jobenddate AND NOW() >= jobstartdate) THEN 1
CASE WHEN jobbusiness=0 AND jobfixedstartdate=0 AND jobfixedenddate=0 AND date_diff(NOW(),jobcreatedtimestamp)>60 THEN 1
CASE WHEN jobbusiness=0 AND jobfixedstartdate=1 AND jobfixedenddate=0 AND jobstartdate>= NOW() THEN 1
CASE WHEN jobbusiness=0 AND jobfixedstartdate=1 AND jobfixedenddate=1 AND jobenddate>=NOW() THEN 1
ELSE 0
END)
好运。
答案 1 :(得分:1)
根据我的理解,这看起来像这样...
From question_ans_word qaw
JOIN uniqueword uw on qaw.keywords_id = uw.id and word like "minimum"
答案 2 :(得分:0)
尝试一下,
select *, count(*) c from question_ans_word qw INNER JOIN uniqueword uw ON uw.id = qw.keywords_id WHERE uw.word like "minimum" group by answer_id