sqlzoo

https://sqlzoo.net/wiki/SELECT_names

  • Find the capital and the name where the capital includes the name of the country.

select capital, name from world where capital like concat('%',name,'%')

  • 14.Find the capital and the name where the capital is an extension of name of the country.
    You should include Mexico City as it is longer than Mexico. You should not include Luxembourg as the capital is the same as the country.
    SELECT capital ,name FROM world WHERE capital like concat(name,'%') AND name != capital;

  • For Monaco-Ville the name is Monaco and the extension is -Ville.
    Show the name and the extension where the capital is an extension of name of the country.
    You can use the SQL function REPLACE.
    select name, replace(capital, name,'') from world where capital like concat(name,'_%');

https://sqlzoo.net/wiki/SELECT_from_WORLD_Tutorial#Large_Countries

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容