[英]How to add new column to MySQL table without listing other existing columns
Say that we have a mysql table that has 100 columns. 假设我们有一个包含100列的mysql表。 Now, I know that if we wanted to have a new column that has the sum of the values of two columns we could use the SUM
function on the two columns after SELECT
, but then I also have to list the names of the other 100 columns. 现在,我知道,如果我们要创建一个包含两列值之和的新列,我们可以在SELECT
之后在两列上使用SUM
函数,但是我还必须列出其他100列的名称。 Is there a way to have a table that has the 100 columns plus the SUM
function without listing those columns after SELECT
. 有没有一种方法可以使表具有100列以及SUM
函数,而不必在SELECT
之后列出这些列。
SELECT c1+c2, c1, c2, c3, c4,...,c100 FROM columns
您可以只使用通配符( *
):
SELECT *, c1 + c2 AS sum FROM columns
尝试:
SELECT c1+c2, t.* FROM columns t
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.