Mysql sql连接以从不同的表中获取数据

Mysql sql连接以从不同的表中获取数据,mysql,sql,Mysql,Sql,如何编写查询以从约会表中获取数据(提供商名称、服务名称、位置名称),该约会表具有时间表表的外键securement_id(f.k)。 时间表表依次具有外键提供程序id(f.k)、服务id(f.k)、位置id(f.k) 你不应该在这里张贴你的作业。如果您在代码方面遇到任何问题,请发布您的代码,我们将提供您的ans。 但我给你这个问题的答案 select p.provider_name,s.name,l.location_name from appointment a,schedule sc,ser

如何编写查询以从约会表中获取数据(提供商名称、服务名称、位置名称),该约会表具有时间表表的外键securement_id(f.k)。 时间表表依次具有外键提供程序id(f.k)、服务id(f.k)、位置id(f.k)


你不应该在这里张贴你的作业。如果您在代码方面遇到任何问题,请发布您的代码,我们将提供您的ans。 但我给你这个问题的答案

select p.provider_name,s.name,l.location_name from appointment a,schedule sc,service s,provider p,location l where
sc.schedule_id=a.schedule_id and
sc.provider_id=p.provider_id and
sc.service_id=s.service_id and
sc.location_id=l.location_id and
a.appointment_id = 'Your id'

希望对您有所帮助。

添加一些示例表数据,以及预期的结果。同时显示您当前的查询尝试。
select p.provider_name,s.name,l.location_name from appointment a,schedule sc,service s,provider p,location l where
sc.schedule_id=a.schedule_id and
sc.provider_id=p.provider_id and
sc.service_id=s.service_id and
sc.location_id=l.location_id and
a.appointment_id = 'Your id'