I am trying to fetch data from two tables. Table 1 is called Location and Table 2 is called Restaurant. Location has a field called RestaurantID (FK) which is the primary key in Restaurant . I want to show the value of column "Location" from table Location and the "RestaurantID" (PK in Restaurant and FK in Location) as well as " Name " value from Table Restaurant . I have attached MySQL table below.
A join should do the trick:
SELECT l.location, l.restaurantid, r.name
FROM location l
JOIN restaurant r ON l.restaurantid = r.restaurantid
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.