Doubt how to query multiple tables with one word

2

I'm setting up a search system, where the user types in a search box any word, eg "Programmer", mysql will have to search that word in several fields in several tables, if by chance he finds that word in some place get back to me who is the professional that gets that word.

Below are the tables and the query I'm currently using, but it's not very functional.

Tables / Columns

Professional:

id

Pri_name

about_name

enderenco_professional:

id

professional_id

status

city

historico_escolar:

id

professional_id

schooling

Experience:

id

professional_id

charge

Query that I'm trying to get right!

SELECT a.id FROM profissional a, endereco_profissional b, historico_escola c, experiencia d WHERE a.pri_nome LIKE '%programador%' OR a.sobre_nome LIKE '%programador%' OR b.estado LIKE '%programador%' OR b.cidade LIKE '%programador%' OR c.escolaridade LIKE '%programador%' OR d.cargo LIKE '%programador%' OR a.id = b.id_profissional OR a.id = c.id_profissional OR a.id=d.id_profissional OR a.id=e.id_profissional OR a.id=f.id_profissional GROUP BY a.id
    
asked by anonymous 27.09.2015 / 07:52

1 answer

1

Class I think I did it. It was just to use a bit more of the logic of the head with the or and and gates.

SELECT a.id FROM profissional a, endereco_profissional b, historico_escola c, experiencia d, area_interesse_profissional e, curso_extra f WHERE a.pri_nome LIKE '%programador%' OR a.sobre_nome LIKE '%programador%' OR (b.estado LIKE '%programador%' AND a.id = b.id_profissional) OR (b.cidade LIKE '%programador%' and a.id = b.id_profissional) OR (c.escolaridade LIKE '%programador%' AND  a.id = c.id_profissional) OR (d.cargo LIKE '%programador%' AND a.id=d.id_profissional)  GROUP BY a.id
    
27.09.2015 / 17:49