简体   繁体   中英

MySQL SELECT with an extra column containing a string

I used to know how to do this, but I can't seem to remember or find the answer.

I want to return data from a table and then just add an extra column with a set value (which does not need to be saved). So, it is not an UPDATE issue. Just a SELECT with that extra column.

Original table:

|  id  |   col1   |   col2   |
|  1   |  value1  |  value2  |

Return something like this:

|  id  |   col1   |   col2   ||    tmpCol    |
|  1   |  value1  |  value2  ||    12:48     |

它很简单:

SELECT id, col1, col2, '12:48' AS tempCol

用这个

select id,col1,col2, '12.48'  as tempcol

try this. alter table TableName add column columnName date ; note, put the exact table name in the "TableName that i defined" that u want to add the column and put the column name where i defined the "columnName"

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