[英]MySQL SELECT with an extra column containing a string
我曾經知道如何做到這一點,但我似乎無法記住或找到答案。
我想從表中返回數據,然后只添加一個帶有設置值的額外列(不需要保存)。 所以,它不是UPDATE
問題。 只是帶有額外列的SELECT
。
原表:
| id | col1 | col2 |
| 1 | value1 | value2 |
返回這樣的東西:
| 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
嘗試這個。 alter table TableName add column columnName date; 注意,將確切的表名放在我想要添加列的“我定義的TableName”中,並將列名放在我定義的“columnName”中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.