Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 *.

like image 616
Not Gabriel Avatar asked Feb 10 '23 18:02

Not Gabriel


1 Answers

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.

like image 200
jarlh Avatar answered Feb 12 '23 10:02

jarlh