Use the command SQL
UNION ALL
example:
(SELECT codigo, data, status
FROM historico WHERE status = 'AVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT codigo, data, status
FROM historico WHERE status = 'FRACASO' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT codigo, data, status
FROM historico WHERE status = 'REAVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT codigo, data, status
FROM historico WHERE status = 'SUCESSO' ORDER BY DATA DESC LIMIT 20)
When using the UNION ALL, makes no distinction in the result obtained (distinct) and brings everything that SQL
satisfy.
This doubt would be your question, but in the comments need all fields, so:
(SELECT * FROM historico WHERE status = 'AVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT * FROM historico WHERE status = 'FRACASO' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT * FROM historico WHERE status = 'REAVALIAR' ORDER BY DATA DESC LIMIT 20)
UNION ALL
(SELECT * FROM historico WHERE status = 'SUCESSO' ORDER BY DATA DESC LIMIT 20)
References
Ever tried a UNION with 4
SELECT
?– novic
Yes, it even returned 50 of each, but when I did the query to return all fields of the table it did not work. For some reason returns fewer values for failure.
– Billly Jow
I made an answer, your comment SQL resembles that ?
– novic