Query
SELECT * FROM stack;
Result
+------+----------+----------+
| id | username | password |
+------+----------+----------+
| 1 | admin | admin |
| 2 | stack | stack |
+------+----------+----------+
2 rows in set (0.00 sec)
You can select all columns from one table in a join by doing:
SELECT stack.* FROM stack JOIN Overflow ON stack.id = Overflow.id;
Best Practice Do not use *
unless you are debugging or fetching the row(s) into associative arrays, otherwise schema changes (ADD/DROP/rearrange columns) can lead to nasty application errors. Also, if you give the list of columns you need in your result set, MySQL's query planner often can optimize the query.
Pros:
SELECT *
SELECT *
-usage ever be justified?Cons:
SELECT *
you can end up returning 2MB per 10 rows that you don't needTEXT
fields, the query may be slowed down by less-optimal temp table processing