我有两张桌子:
dbo.Events
EventID EventName Location
1 Birthday Party 2
2 Wedding 1
dbo.EventsLocation
Location LocationName
1 Room 1
2 Room 2
我想创建一个返回以下内容的SQL查询
Birthday Party Room 2
Wedding Room 1
答案 0 :(得分:12)
SELECT
Events.EventName AS EventName,
EventsLocation.LocationName AS LocationName
FROM
Events
INNER JOIN EventsLocation ON Events.Location=EventsLocation.Location
(WHERE ...)
;
答案 1 :(得分:1)
加入表格:
select e.EventName, l.LocationName
from Events e
inner join EventsLocation l on l.Location = e.Location
答案 2 :(得分:0)
Select e.eventname, l.locationname
From events e
Left join eventslocation l
On e.location = l.location
答案 3 :(得分:0)
select
e.eventName,
el.locationName
from
Events e
join EventsLocation el
on e.location = el.location
答案 4 :(得分:0)
SELECT E.EventName,EL.LocationName
FROM dbo.Events E
INNER JOIN EventsLocation EL
ON E.Location=EL.Location