假设景点表为 'scenery',类型表为 'category',关联表为 'scenery_category'。

查询两个表的信息,可以使用以下 SQL 语句:

SELECT scenery.scenery_id, scenery.scenery_name, category.category_name
FROM scenery
JOIN scenery_category ON scenery.scenery_id = scenery_category.scenery_id
JOIN category ON scenery_category.category_id = category.category_id;

该语句使用了两次 JOIN 操作,将三个表联接在一起。结果集包含景点 ID、景点名称和景点所属的类型名称。

SQL 查询景点信息:连接景点表和类型表

原文地址: https://www.cveoy.top/t/topic/nw5t 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录