小编典典

SQL查询根据另一个表中的id查找返回值

sql

我有2张桌子:

    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

阅读 206

收藏
2021-04-22

共1个答案

小编典典

SELECT
  Events.EventName AS EventName,
  EventsLocation.LocationName AS LocationName
FROM
  Events
  INNER JOIN EventsLocation ON Events.Location=EventsLocation.Location
(WHERE ...)
;
2021-04-22