本文介绍了在SELECT中包括一个实际上不在数据库中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行包含静态字符串值列的SELECT语句.我已经在Access中完成了此操作,但从未使用原始SQL进行过.这可能吗?

I'm trying to execute a SELECT statement that includes a column of a static string value. I've done this in Access, but never with raw SQL. Is this possible?

示例:

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

在上面的示例中,数据库中不存在状态"列.

In the above example, the "Status" column doesn't exist in the database.

推荐答案

您可能要使用:

SELECT Name, 'Unpaid' AS Status FROM table;


SELECT子句语法,如 MSDN:SELECT子句(Transact -SQL),如下所示:


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> 

expression可以是常数,函数,列名,常数和由一个或多个运算符或子查询连接的函数的任意组合.

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.

这篇关于在SELECT中包括一个实际上不在数据库中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 20:04