00:11
SELECT 0 AS visita, id_cliente AS cliente,2 AS operacion FROM clientesdatosgenerales WHERE noPedido = 1 OR noVisita=1
That creates a row for every item in the 'clientesdatosgenerales' table
But I want to select only the 'id_cliente' from clientesdatosgenerales that match the 'no_cliente' from a table called noproductivo
select 0 as visita, id_cliente as cliente,2 as operacion, n.fecha as fecha_no_visita from clientesdatosgenerales c inner join noproductivo n where noPedido = 1 or noVisita=1 and n.no_cliente=c.id_cliente
But it's creating a row for every item in the table clientesdatosgenerales and noproductivo
And I only need the clientesdatosgenerales items
How can I accomplish that?