0

Write the SQL query that can show which parties have candidates in all districts

There are 3 tables-parties, districts, candidates. table name: Parties Column name: party Conservative Green Liberal Libertarian Socialist table:Districts column names: district Essex Malton Riverdale Guelph Halton table: Candidates coloumn names : id, name, district, party 1 | Anne Jones | Essex | Liberal | 2 | Mary Smith | Malton | Liberal | 3 | Sara Black | Riverdale | Liberal | 4 | Paul Jones | Essex | Socialist | 5 | Ed White | Essex | Conservative | 6 | Jim Kelly | Malton | Liberal | 7 | Fred Price | Riverdale | Socialist | 8 | Bill Green | Guelph | Green | 9 | Garth Adams | Halton | Libertarian | 10 | Sam Adams | Guelph | Liberal | 11 | Jill Mackay | Halton | Liberal

26th Mar 2021, 4:31 PM
Blesson T Sunny
Blesson T Sunny - avatar
7 Réponses
+ 4
Blesson T Sunny Try this once Select party from Parties p INNER JOIN Candidates c ON p. party = c. party INNER JOIN District d ON d. district = c. district
26th Mar 2021, 7:03 PM
A͢J
A͢J - avatar
+ 3
select party from candidates group by party having count(distinct district)>=(select count(distinct district) from districts);
1st Apr 2021, 5:55 PM
FLASH RETRY
FLASH RETRY - avatar
+ 1
Blesson T Sunny Show your attempt
26th Mar 2021, 4:54 PM
R🍁🇮🇳
R🍁🇮🇳 - avatar
0
SELECT party FROM candidates WHERE district='Essex'AND district='Malton'AND district='Riverdale' AND district='Guelph' AND district='Halton';
26th Mar 2021, 6:18 PM
Blesson T Sunny
Blesson T Sunny - avatar
0
Hey Blesson, Did you solve it? What's the right working query?
27th Mar 2021, 3:15 PM
Meet Singh
Meet Singh - avatar
0
Meet Singh I tried.but didn't get the right code.
27th Mar 2021, 4:24 PM
Blesson T Sunny
Blesson T Sunny - avatar
0
Thanks a lot.It worked.
2nd Apr 2021, 4:42 AM
Blesson T Sunny
Blesson T Sunny - avatar