我有两列,其中一个是外国 ID,我怎样才能将它们连接成一列?
例子:
StateID = 1
Area = "Bronx"
成为:
New York - Bronx
编辑:
Table1 = [Address] has two columns, (ID, Name)
Table2 = [Requests] has many columns including (Area, StateID)
我有两列,其中一个是外国 ID,我怎样才能将它们连接成一列?
例子:
StateID = 1
Area = "Bronx"
成为:
New York - Bronx
编辑:
Table1 = [Address] has two columns, (ID, Name)
Table2 = [Requests] has many columns including (Area, StateID)
用于+
连接列:
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 )
SELECT StateID + ' - ' + Area AS SateArea