mysql 语句中的 * 星号是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6824414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:36:46  来源:igfitidea点击:

What does the * asterisk mean in a mysql statement?

mysql

提问by user784637

Ex. mysql_query("SELECT * FROM members WHERE id='$id');

回答by Jon Martin

It means select all columns in the table.

这意味着选择表中的所有列。

回答by aldavigdis

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'

回答by Geoffrey Fuller

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.

它的意思是“全选”,指的是引用表中的所有列。问题与*使用现有表的插入语句或静态报告模板中使用的选择语句有关。引用表中的任何更改都将导致使用 * 返回的结果集发生更改。如果插入或报表源记录集有任何额外的或缺少的列,查询可能会中断。主要的一点是,使用*可能会给您带来不一致的列和记录集。

回答by Nikola Despotoski

Select ALL fields from some table.

从某个表中选择所有字段。

回答by Jesus Ramos

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

这是一个通配符,它​​意味着返回结果集中该表的所有列。