Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am having the following two tables:

    dbo.Events

    EventID               EventName            Location
    1                     Birthday Party       2
    2                     Wedding              1

    dbo.EventsLocation

    Location    LocationName
    1           Room 1
    2           Room 2

I want to make an SQL query that returns the following:

    Birthday Party    Room 2
    Wedding           Room 1

1 Answer

0 votes
by (12.7k points)

You can use the following code for this, it will do the magic for you:

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

Want to get certified in SQL? Register for this complete SQL Course by Intellipaat. 

Watch this video tutorial on how to become a professional in SQL.

Browse Categories

...