简体   繁体   中英

How to add new column to MySQL table without listing other existing columns

Say that we have a mysql table that has 100 columns. 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. Is there a way to have a table that has the 100 columns plus the SUM function without listing those columns after 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM