12

I'm using UNION to get all names in different tables.
my tables has about 10000 rows all together.
but the query returns 468 rows!!
My query is:

SELECT name FROM `shopping` 
UNION 
SELECT name FROM stores 
UNION 
SELECT name FROM concert 
UNION 
SELECT val AS name FROM event 
UNION 
SELECT name FROM fastfood

Where is the problem?

Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235
Ariyan
  • 14,760
  • 31
  • 112
  • 175

1 Answers1

31

UNION removes duplicate values. You probably want UNION ALL instead.

Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235