为什么星号必须先出现? [英] Why must the asterisk come first?

查看:93
本文介绍了为什么星号必须先出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MySQL中,select *,1 from t似乎有效,但select 1,* from t无效.

In MySQL, select *,1 from t appears to be valid, but select 1,* from t is not.

  1. 那是为什么?
  2. 是否有任何官方文件?我找不到任何表示后者无效的信息,并且我收到的错误消息也没有具体说明任何信息.

推荐答案

从MySQL文档,您将被告知您可以对不合格的*:

From the MySQL docs, you are told what you can do with the unqualified *:

仅由一个不合格的*组成的选择列表可以用作从所有表中选择所有列的速记:

A select list consisting only of a single unqualified * can be used as shorthand to select all columns from all tables:

SELECT * FROM t1 INNER JOIN t2 ...

您正在寻找的相关文档下面是两个要点:

The pertinent documentation you're looking for is two bullet points below that:

将不合格的*与选择列表中的其他项目一起使用可能会产生解析错误.为避免此问题,请使用合格的tbl_name.*参考

Use of an unqualified * with other items in the select list may produce a parse error. To avoid this problem, use a qualified tbl_name.* reference

不幸的是,文档中没有解释为什么,因此可能需要进行一些挖掘.

Unfortunately the why is not explained in the docs, and would likely take some digging.

这篇关于为什么星号必须先出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆