I am trying to create a SELECT query that combines 3 tables via LEFT JOIN
and then MATCH
specific keywords AGAINST
the resulting table.
My testing so far reveals that the query is working fine and the output results are correct, however I have a doubt about FULLTEXT indexes when joining tables via LEFT JOIN
.
The question is - should I add additional code to reflect the FULLTEXT
index requirement for MATCH AGAINST
when doing LEFT JOIN
or only correct indexing of the relevant columns in the original tables is enough?
Reason for asking is this post. If I understand it correct my code should not work (since "You can't define fulltext indexes...across multiple tables in MySQL"). Therefore MATCH AGAINST
for ma.name_url
and v.model
, would not work as they are not indexed (or this how I understand it, correct me if I am wrong :) ).
However, as the query output seems to be correct I need an expert advice if the below code is correct or I should add/modify something:
SELECT v.*, vt.color, ma.*
FROM tbl_items AS v
LEFT JOIN tbl_options
AS vt on v.id = vt.v_id
LEFT JOIN tbl_names
AS ma on v.make = ma.id
WHERE
(
(
MATCH (ma.name_url) AGAINST ('keyword1' IN BOOLEAN MODE)
OR MATCH (v.model) AGAINST ('keyword1' IN BOOLEAN MODE)
)
AND
(
MATCH (ma.name_url) AGAINST ('keyword2' IN BOOLEAN MODE)
OR MATCH (v.model) AGAINST ('keyword2' IN BOOLEAN MODE)
)
)
AND v.type = 4