我有下表
+-----+------------------+-------------+
| id | datenum | F1_baro_20_ |
+-----+------------------+-------------+
| 1 | 734152.000000000 | 1005.21 |
| 2 | 734152.006944445 | 1005.26 |
+-----+------------------+-------------+
当我做出选择时,我想再添加一列。
例如
SELECT id,datenum, F1_baro_20_ FROM test
我想添加一个列,如下所示:
SELECT id,datenum, F1_baro_20_, new_column=1 FROM test
+-----+------------------+-------------+------------+
| id | datenum | F1_baro_20_ |new_column |
+-----+------------------+-------------+------------+
| 1 | 734152.000000000 | 1005.21 | 1 |
| 2 | 734152.006944445 | 1005.26 | 1 |
+-----+------------------+-------------+------------+
答案 0 :(得分:9)
SELECT id, datenum, F1_baro_20_, 1 AS new_column FROM test;
这甚至适用于更复杂的表达式,如:
SELECT id, datenum, F1_baro_20_, (IF id = 2 THEN 1 ELSE 0) AS id_is_two FROM test;