Looking at your SQL
to see that it was not very clear to you how to make relationships in JOINS
, I recommend you read here: What is the difference between INNER JOIN and OUTER JOIN? p>
Leaving for your problem, I would do something like this:
SELECT * FROM cliente as c
INNER JOIN cliente_contato as ct ON ct.id_cliente = c.id
INNER JOIN cliente_ip as cip ON cip.id_cliente = c.id
INNER JOIN cliente_mac as mac ON mac.id_cliente = c.id
INNER JOIN cliente_pppoe as pppoe ON pppoe.id_cliente = c.id
In this way all tables are linked by their id_cliente
, guaranteeing data integrity, if any of these tables is not mandatory in your result you can change INNER
by LEFT
.
Leaving for your research:
WHERE ct.nome LIKE '%{$pesquisa}%'
OR ct.telefone LIKE '%{$pesquisa}%'
OR cip.detalhes LIKE '%{$pesquisa}%'
OR mac.detalhes LIKE '%{$pesquisa}%'
OR pppoe.usuario LIKE '%{$pesquisa}%'
OR c.nome LIKE '%{$pesquisa}%'
That way it will bring the result if only one of the conditions meet.
Final Code
SELECT * FROM cliente as c
INNER JOIN cliente_contato as ct ON ct.id_cliente = c.id
INNER JOIN cliente_ip as cip ON cip.id_cliente = c.id
INNER JOIN cliente_mac as mac ON mac.id_cliente = c.id
INNER JOIN cliente_pppoe as pppoe ON pppoe.id_cliente = c.id
WHERE ct.nome LIKE '%{$pesquisa}%'
OR ct.telefone LIKE '%{$pesquisa}%'
OR cip.detalhes LIKE '%{$pesquisa}%'
OR mac.detalhes LIKE '%{$pesquisa}%'
OR pppoe.usuario LIKE '%{$pesquisa}%'
OR c.nome LIKE '%{$pesquisa}%'