List two mysql tables pdo

0
$catalog = $dbh->prepare("SELECT * FROM catalogo WHERE ativo = 2 ORDER BY catalogo_view DESC LIMIT 0,5");
$catalog->execute();

I want to search between two tables, how do I?

    
asked by anonymous 26.02.2016 / 19:09

1 answer

0

Try to use UNION, but remembering that in UNION the query columns must have the same amount.

SELECT cliente_codigo, cliente_nome FROM cliente
UNION SELECT funcionario_codigo, funcionario_nome FROM funcionario
WHERE ativo = 2
    
26.02.2016 / 20:37