Multiple choice

Which of the following is a valid statement to select all the records from a table named city where the value of the column cityname starts with an 'A'?

  1. SELECT * FROM city WHERE cityname = '%A%'

  2. SELECT * FROM city WHERE cityname = 'A'

  3. SELECT * FROM city WHERE cityname LIKE '%A'

  4. SELECT * FROM city WHERE cityname LIKE 'A%'

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The above statement will print all those records where the city name starts with 'A'. The wildcard character '%' is used to substitute a whole string. Therefore all those city names will be printed that begins with 'A'. For example, 'Ahemdabad', 'Akola' etc.