开发者

What does the * asterisk mean in a mysql statement?

开发者 https://www.devze.com 2023-03-23 09:09 出处:网络
Ex. mysql_query(\"SELECT * FROM members WHERE id=\'$id\'); 开发者_如何转开发It means select all columns in the table.It means that you are selecting every column in the table. This is something you sh
Ex. mysql_query("SELECT * FROM members WHERE id='$id');
开发者_如何转开发


It means select all columns in the table.


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'


Select ALL fields from some table.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消