假设我有两个简单的表,programs
和seasons
:
programs
| id | season_id | title |
| 1 | 1 | Program 1 |
| 2 | 1 | Program 2 |
| 3 | 2 | Program 3 |
seasons
| id | season |
| 1 | Season 1 |
| 2 | Season 2 |
真的没有超级幻想,所以现在运行以下命令:
SELECT
programs.title, seasons.season
FROM
programs
LEFT JOIN seasons ON programs.season_id = seasons.id;
给我一个预期的结果:
| title | season |
| Program 1 | Season 1 |
| Program 2 | Season 1 |
| Program 3 | Season 2 |
但是实际结果如下:
| title | season |
| Program 1 | NULL |
| Program 2 | NULL |
| Program 3 | NULL |
这是什么原因以及如何补救?
答案 0 :(得分:0)
根据您提供的表格结构,应该是seasons.season而不是seasons.name