Ex. mysql_query("SELECT * FROM members WHERE id='$id');
-
2It means "all fields (columns)" – ypercubeᵀᴹ Jul 26 '11 at 01:57
-
2Related: http://stackoverflow.com/questions/3639861/why-is-select-considered-harmful – OMG Ponies Jul 26 '11 at 01:58
-
What would something like `Order.select('orders.*')` mean? – Jwan622 Jul 14 '16 at 15:05
5 Answers
It means that you are selecting every column in the table. This is something you should avoid in production environments though because it causes a bit of overhead and things tend to break when you alter your tables and use the *
selector.
A better way to do this is to select only the columns you need each time, like the following example:
SELECT `id`, `firstName`, `lastName` FROM members WHERE id='$id'

- 635
- 6
- 17
It means "Select All", referring to all columns in referenced table. The issue with *
relates to insert statements with existing tables or select statements used in a static report template. Any change in the referenced table would cause a change in the returned result set using *. If the insert or report source recordset has any additional or missing columns, the query may break. The main point is that using *
can give you inconsistent columns and recordsets.

- 186
- 1
- 6
-
1This should probably be a comment on the answer you've referenced since it doesn't answer the question itself. – Jeff B Mar 23 '17 at 21:31
-
1That's a fair point. I just wanted to give some examples of the issue that I have encountered. I don't have enough reputation points to post a comment to someone else's answer. – Geoffrey Fuller Mar 23 '17 at 21:38
-
This is the best answer, since it tells readers why using it is not a golden hammer solution. – Robert Columbia Jun 05 '19 at 15:47
It's a wildcard it means return all columns for that table in the result set.

- 22,940
- 10
- 58
- 88