I want to create a prediction table that lists each of the 10 teams playing every other team at home and away. How can I generate this table?
1Times asked
Jun 2026Last seen
Jun 2026First seen
💡 Model Answer
Create a temporary table or CTE that holds the team list, then cross‑join it with itself to get all combinations, filtering out self‑matches. Finally, insert the result into a prediction table. Example in PostgreSQL:
sql
-- Create prediction table
CREATE TABLE predictions (
home_team_id INT,
away_team_id INT,
predicted_score_home INT,
predicted_score_away INT
);
-- Generate all home‑away pairs
INSERT INTO predictions (home_team_id, away_team_id)
SELECT t1.team_id, t2.team_id
FROM teams t1
JOIN teams t2 ON t1.team_id <> t2.team_id;If you need both directions (home and away) for each pair, just run the same insert again or use UNION ALL. The resulting table will have 10 × 9 = 90 rows. Complexity is O(n²).
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500