Hello !
I'm trying to build a search engine that will search all words in any table that has a relation with my "t_programs" table.
It is always an any-any relation. My programs have multiple writers, multiple themes, multiple cycle ...
I tried this :
SELECT
DISTINCT(P.program_id) ,
P.*
FROM
t_programs AS P
, t_writers AS T0
, r_programs_writers AS R0
, t_themes AS T1
, r_programs_themes AS R1
, t_cycles AS T2
, r_programs_cycles AS R2
WHERE 1
AND ( P.program_id = R0.fk_program_id AND R0.fk_writer_id = T0.writer_id )
AND ( P.program_id = R1.fk_program_id AND R1.fk_theme_id = T1.theme_id )
AND ( P.program_id = R2.fk_program_id AND R2.fk_cycle_id = T2.cycle_id )
AND (
T0.writer_label LIKE "%word1%"
OR T1.theme_label LIKE "%word1%"
OR T2.cycle_label LIKE "%word1%"
) AND (
T0.writer_label LIKE "%word2%"
OR T1.theme_label LIKE "%word2%"
OR T2.cycle_label LIKE "%word2%"
)
I want the programs related to word1 AND word2. This request works fine, as soon as the programs have at least one relation with all the tables. But if the two words are in the t_themes.theme_label, and that the program has no cycle, it won't return. Is there a way to return to results two ? I'm not familiair with the JOIN syntax ...
Thanx in advance !
(and sorry for my english)
Gavroche Le Gnou