vincent
vincent

Reputation: 205

union is merging results

i have a query that looks as following:

(SELECT title FROM pjeducations LIMIT 5)
UNION
(SELECT title FROM pjeducations WHERE animal != "all" LIMIT 5)
UNION
(SELECT title FROM pjeducations ORDER BY price DESC LIMIT 5)

Some of the results in the second select are the same as in the first, same with the third select.

The problem is that the duplicate results automaticly get removed but i would like them to stay in it. Anyone know how to achieve this?

Upvotes: 1

Views: 234

Answers (2)

Ali Tarhini
Ali Tarhini

Reputation: 5358

Union All 

preserved duplicate results

Upvotes: 3

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171411

Use UNION ALL instead.

Upvotes: 8

Related Questions