gpt4 book ai didi

php - MySQL:用第二个查询的结果替换第一个查询的结果

转载 作者:行者123 更新时间:2023-11-29 23:46:58 24 4
gpt4 key购买 nike

我有 2 张 table :

表1:时间表

monday  tuesday  wednesday
------ ------- ---------
18 15 2
10 8 6

表2:主题

subject_id  subject_name  
---------- ------------
18 maths
10 history
8 english

结果应如下所示:

    monday   tuesday   wednesday  
------- -------- ---------
maths phy phy
history history phy
english chem phy

我该怎么做?

最佳答案

SELECT ms.subject_name as moday,
ts.subject_name as tuesday,
ws.subject_name as wednesday
FROM timetable t
INNER JOIN subjects ms ON t.monday = ms.subject_id
INNER JOIN subjects ts ON t.tuesday = ts.subject_id
INNER JOIN subjects ws ON t.wednesday = ws.subject_id

关于php - MySQL:用第二个查询的结果替换第一个查询的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25862439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com