Search code examples
mysqlsqlxampp

Find the name and IMDB rating of all the movies which contain either 1 or, 2 or, 3 or.... 20 characters in their name


I have a movie table inside my Movie_Info database which content Movie_Name, Movie_ID, IMDB_Rating etc fields. Like this:

enter image description here

Now I want to fetch the name and IMDB rating of all the movies which contain total 1~20 numbers of characters in their name.

What should be the SQL query for it?


Solution

  • here is the full query you need:

    select 
       name, IMDB_rating
    from Movie_Info
    where length(Movie_name) between 1 and 20