MySQL Join And Case Select SQL





 SELECT
country.NAME AS 'country_name',
city.NAME AS 'city_name',
city.district,
city.population AS 'population',
CASE

WHEN city.id = country.capital THEN
city.NAME ELSE '' 
END AS 'capital_name' 
FROM
city
INNER JOIN country ON city.CountryCode = country.
CODE INNER JOIN countrylanguage ON country.CODE = countrylanguage.CountryCode 
GROUP BY
city.NAME,
city.district,
country.NAME;
ORDER BY
country.NAME ASC;

OUTPUT:



Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment