TransWikia.com

Listar duas tabelas mysql pdo

Stack Overflow em Português Asked by Leno Sousa on December 11, 2020

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

Quero buscar entre duas tabelas, como faço?

One Answer

Tente usar UNION, mas lembrando que no UNION as colunas da consulta tem que ter a mesma quantidade.

SELECT cliente_codigo, cliente_nome FROM cliente
UNION SELECT funcionario_codigo, funcionario_nome FROM funcionario
WHERE ativo = 2

Answered by graciomar on December 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP