这是我原来的表格。
+----------+---------------------+--------+------------+-------+
| lab_code | test_name | sample | time_taken | price |
+----------+---------------------+--------+------------+-------+
| FBS | Fasting blood Suagr | Blood | 01:15:00 | 400 |
| STLC | Stool Culture | Stool | 48:00:00 | 700 |
| UA | Urinalysis | Urine | 02:30:00 | 425 |
| UDS | Urine drug screen | Urine | 06:00:00 | 550 |
+----------+---------------------+--------+------------+-------+
我想要显示
+----------+
| Hospital |
+----------+
| FBS |
| STLC |
| UA |
| UDS |
+----------+
我希望在数据查询时更改属性名称。(不更改原始表格) 请帮助。
答案 0 :(得分:5)
将ALIAS
名称提供给特定列
SELECT lab_code AS Hospital
From tableA
答案 1 :(得分:2)
怎么样?
SELECT lab_code AS Hospital FROM <table_name>;
AS的使用是 ALIAS ,可用于列名;它并不意味着表的列名更改,而是在执行SELECT查询时,它将成为表中当前列名的列名或别名。
答案 2 :(得分:2)
试试这个
SELECT lab_code AS Hospital From original_table
它可以使用AS
SELECT lab_code Hospital From original_table
答案 3 :(得分:1)
试试这个
aliases
用于临时重命名列名(或其他情况下的表名)
SELECT lab_code AS Hospital FROM Table
答案 4 :(得分:1)
SELECT lab_code AS Hospital
FROM Original_Table
答案 5 :(得分:1)
试试这个:
SELECT "lab_code" AS "Hospital" FROM "table";
答案 6 :(得分:1)
如果lab_code不是主键,请使用此查询
SELECT DISTINCT lab_code AS Hospital
FROM myTable