在 SELECT 中包含一个实际上不在数据库中的列

我试图执行一个 SELECT 语句,该语句包含一个静态字符串值列。我在 Access 中这样做过,但从未使用原始 SQL。这可能吗?

例如:

 Name  | Status
------+--------
John  | Unpaid
Terry | Unpaid
Joe   | Unpaid

在上面的示例中,数据库中不存在“ Status”列。

227247 次浏览

You may want to use:

SELECT Name, 'Unpaid' AS Status FROM table;

The SELECT clause syntax, as defined in MSDN: SELECT Clause (Transact-SQL), is as follows:

SELECT [ ALL | DISTINCT ]
[ TOP ( expression ) [ PERCENT ] [ WITH TIES ] ]
<select_list>

Where the expression can be a constant, function, any combination of column names, constants, and functions connected by an operator or operators, or a subquery.