sqlzoo

作者: 刘小小gogo | 来源:发表于2020-11-25 16:59 被阅读0次

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

相关文章

网友评论

      本文标题:sqlzoo

      本文链接:https://www.haomeiwen.com/subject/itsniktx.html