Mysql - List results from 2 tables

Asked

Viewed 45 times

1

I have two tables with the same field and I need to make a SELECT with two conditions, I’m trying this code but is listing 2 times the result only from the first table (entrada), nothing from the second table (saida):

SELECT * FROM entrada, saida WHERE entrada.idUsuario = '1' OR saida.idUsuario = '1';

1 answer

1

I got it using UNION:

(SELECT * FROM entrada WHERE idUsuario LIKE '1')
UNION 
(SELECT * FROM saida WHERE idUsuario LIKE '1')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.