2
I am setting up a search system, where the user type in a search box any word, Example "Programmer", mysql will have to search that word in various fields in various table, if by chance he finds that word somewhere return to me who is the professional who gets that word.
Below are the tables and the query I’m using at the moment, but it’s not very functional.
Tables/columns
Professional:
id
Pri_name
surname
address_professional:
id
id_professional
state
city
school history:
id
id_professional
schooling
experience:
id
id_professional
office
Query I’m trying to hit!
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
I believe making relationship with the tables. After you make a select Join with all the tables at once
– Thalles Daniel
Your tables contain only these columns?
– Thalles Daniel
No, they all contain id, the main table and the professional table, and the others contain their own id and the professional id_id.
– Romario Pires
They’re all related now.
– Romario Pires
If they are related then just make a select with Join.
– Thalles Daniel