Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the * asterisk mean in a mysql statement?

Tags:

mysql

Ex. mysql_query("SELECT * FROM members WHERE id='$id');
like image 507
user784637 Avatar asked Jul 26 '11 01:07

user784637


People also ask

What does * mean in MySQL?

It's a wildcard it means return all columns for that table in the result set.

Why is select * used in MySQL?

SELECT is used to retrieve rows selected from one or more tables, and can include UNION operations and subqueries. Beginning with MySQL 8.0.

What does the asterisk (*) mean when used in the select clause?

Selecting All Fields. The asterisk "*" is used in conjunction with the SELECT keyword to select all fields from a table or a query.

What does the asterisk (*) after select tell the database to do?

The asterisk tells the database to select all data in the table.


3 Answers

It means select all columns in the table.

like image 60
Jon Martin Avatar answered Nov 11 '22 01:11

Jon Martin


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'
like image 38
aldavigdis Avatar answered Nov 11 '22 02:11

aldavigdis


Select ALL fields from some table.

like image 38
Nikola Despotoski Avatar answered Nov 11 '22 01:11

Nikola Despotoski