Not Gabriel
Not Gabriel

Reputation: 561

Is there a difference between SELECT * and SELECT ALL?

Basically this. I wonder if someone would use ALL instead of *, since I'm building automatized SELECT queries. Currently, if someone wants to select everything, the query will just use *.

Upvotes: 9

Views: 13872

Answers (1)

jarlh
jarlh

Reputation: 44786

SELECT ALL means ALL rows, i.e including duplicate rows. (The opposite is SELECT DISTINCT, where duplicate rows are removed.) ALL is the default, and most people write just SELECT instead of SELECT ALL.

SELECT * means all columns.

Note: When it comes to e.g. UNION suddenly DISTINCT is the default. So just UNION means UNION DISTINCT, i.e. duplicate rows are removed. Here you have to specify UNION ALL to keep duplicate rows.

Upvotes: 17

Related Questions