CREATE VIEW Tournament_Winners AS
SELECT tournament_no, player_no FROM Results WHERE position = 1
SELECT tornament_name FROM Tournament WHERE Tournamnet.tournament_no = Results.tournament_no;
我还尝试使用JOIN实现这个:
SELECT tournament_no, player_no FROM Results WHERE position = 1
FULL JOIN Tournament
ON Tournament.tournament_no = Results.tournament_no;
都没有效果。
答案 0 :(得分:4)
CREATE OR REPLACE VIEW Tournament_Winners AS
SELECT a.tournament_no, a.player_no, b.tornament_name
FROM Results a,Tournament b
where a.tournament_no=b.tournament_no and a.position=1
答案 1 :(得分:1)
对于前一个视图中的前两个结果不起作用
对于第二个,您需要处理语法/顺序
SELECT
FROM
WHERE
GROUP BY
ORDER BY
HAVING
SELECT tournament_no, player_no
FROM Results
FULL JOIN Tournament
ON Tournament.tournament_no = Results.tournament_no
WHERE position = 1