0
I have 3 tables:
enterprise:
id integer
nome string
category:
id integer
idEmpresa integer
nome string
tag:
id integer
idEmpresa integer
nome string
I am consulting as follows:
SELECT
distinct(e.nome),
e.id,
e.logo
FROM empresas e,
tags t
where (e.nome like '%texto%'
or e.subcategoria like '%texto%'
or t.tag like '%texto%')
and t.idEmpresa = e.id
and e.logo is not null
order by rand()
It queries correctly, but only if there is a registered tag linked to the company, if it does not exist, it ignores the registration.
How to search a company by name, category or tag, regardless of having a registration tag?
This form of select 'select from Tabela1, table2 ...' Make an INNER Join, you need a left Join
– edson alves