1
I have the following mysql code:
(SELECT * FROM entrada WHERE idUsuario = "1") UNION
(SELECT * FROM saida WHERE idUsuario = "1")
It’s all working but I need to know which of the 2 tables the result came from, how do I do it ?
1
I have the following mysql code:
(SELECT * FROM entrada WHERE idUsuario = "1") UNION
(SELECT * FROM saida WHERE idUsuario = "1")
It’s all working but I need to know which of the 2 tables the result came from, how do I do it ?
4
You can try:
(SELECT 'entrada' as tipo, entrada.* FROM entrada WHERE idUsuario = "1") UNION
(SELECT 'saida' as tipo, saida.* FROM saida WHERE idUsuario = "1")
Thus, in each record will have a column tipo
with the value entrada
or saida
.
Browser other questions tagged mysql sql
You are not signed in. Login or sign up in order to post.