MySQL Forums
Forum List  »  Newbie

Re: Need help with a query
Posted by: danish hafeez
Date: February 21, 2024 12:31AM

Certainly! To identify countries where the official languages are the same as the official languages of Seychelles, you'll need to perform a query that involves joining the necessary tables and filtering the results. Here's how you can do it:

SELECT DISTINCT c1.Name AS Country
FROM countrylanguage cl1
JOIN country c1 ON cl1.CountryCode = c1.Code
JOIN country c2 ON c2.Name = 'Seychelles'
JOIN countrylanguage cl2 ON cl2.CountryCode = c2.Code
WHERE cl1.Language = cl2.Language
AND c1.Code != c2.Code;

countrylanguage table contains information about languages spoken in each country.
country table contains information about countries.
We're joining countrylanguage twice, once for the target country (Seychelles) and once for the candidate countries.
We then join country to get the country names.
We filter the results to include only countries where the language is the same as in Seychelles but exclude Seychelles itself.
This query will give you a list of countries where the official languages are the same as Seychelles. Make sure to replace 'Seychelles' with the appropriate country name if it's different in your database.

Options: ReplyQuote


Subject
Written By
Posted
February 20, 2024 12:21PM
Re: Need help with a query
February 21, 2024 12:31AM
February 21, 2024 03:59AM
February 23, 2024 04:37AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.