1
我有一個存儲的過程,搜索像波紋管:搜索數組元素
BEGIN
#At first, Search in name of job:
(SELECT * FROM tb_job WHERE `name` LIKE '%some%' AND `name` LIKE '%thing%')
UNION
# second, search for tags:
(SELECT * FROM tb_job WHERE id IN
(
SELECT idJob FROM
(
(SELECT 2 AS priority1, COUNT(tb_job_tag.idTag) AS priority2, idJob FROM tb_job_tag WHERE idTag IN
(SELECT tb_tag.id FROM tb_tag WHERE tag LIKE '%some%' OR tag LIKE '%thing%')
GROUP BY tb_job_tag.idJob)
UNION
(SELECT 1, COUNT(tb_job_tag.idTag), idJob FROM tb_job_tag WHERE idTag IN
(SELECT tb_tag.id FROM tb_tag WHERE tag LIKE '%some%' AND tag LIKE '%thing%')
GROUP BY tb_job_tag.idJob)
)
AS t ORDER BY priority1, priority2 DESC
)
)
END
現在我有2個問題:如何傳遞字的陣列,並將它們在MySQL分離並在LIKE
使用它們?第二,我如何使這個搜索更好?
(我有3table:tb_job,tb_tag,tb_job_tag存儲作業的ID和標籤的ID)。謝謝你的幫助。
感謝。但我的問題不是分裂一個短語,實際上是訪問我的SELECT查詢中的每個分離的項目。 – Highlan
@Highlan檢查出第二個查詢,它按照您的要求執行相同操作。 –