2 つの列があり、そのうちの 1 つは外部 ID です。それらを 1 つの列に連結するにはどうすればよいですか?
例:
StateID = 1
Area = "Bronx"
なるために:
New York - Bronx
編集:
Table1 = [Address] has two columns, (ID, Name)
Table2 = [Requests] has many columns including (Area, StateID)
2 つの列があり、そのうちの 1 つは外部 ID です。それらを 1 つの列に連結するにはどうすればよいですか?
例:
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