I have a table with multiple type values and I'm wanting to get a sample records from some of them.
My current query is as follows:
-- Pulling three sample records from each "type"
SELECT * FROM example WHERE type = "A" LIMIT 3
UNION ALL
SELECT * FROM example WHERE type = "B" LIMIT 3
UNION ALL
SELECT * FROM example WHERE type = "C" LIMIT 3
;
I expect this to return a total of 9 records; 3 from type = "A", 3 from type = "B", and 3 from type = "C".
However, the result that I actually receive is 3 records from type = "A" and nothing else.
I know for a fact that the other type values exist because I can run the individual SELECT statements and they return results.
Why is MySQL only returning 3 records and how can I have it return the full 9 records that I want?
I've created a SQL Fiddle to illustrate the issue: http://ift.tt/1SIJUZB
via Chebli Mohamed