0

我有两列,其中一个是外国 ID,我怎样才能将它们连接成一列?

例子:

StateID = 1
Area = "Bronx"

成为:

New York - Bronx

编辑:

Table1 = [Address] has two columns, (ID, Name)
Table2 = [Requests] has many columns including (Area, StateID)
4

2 回答 2

1

用于+连接列:

SELECT a.Name + ' - ' + r.Area As StateAndArea
FROM dbo.Requests r INNER JOIN dbo.Address a
    ON r.StateID = a.ID
ORDER BY StateAndArea -- ( alias can be used in order by but not in where )

+(字符串连接)

于 2013-09-11T15:30:36.803 回答
0
SELECT StateID + ' - ' + Area AS SateArea
于 2013-09-11T15:30:16.073 回答