157k views
1 vote
Modify the select statement to select movies with the word 'star' somewhere in the title. What SQL statement achieves this?

A) SELECT * FROM movies WHERE title LIKE '%star%'
B) SELECT * FROM movies WHERE title = 'star'
C) SELECT * FROM movies WHERE title CONTAINS 'star'
D) SELECT * FROM movies WHERE title BEGINS WITH 'star'

User RobS
by
8.3k points

1 Answer

2 votes

Final answer:

The correct SQL command to find movies with 'star' in the title is 'SELECT * FROM movies WHERE title LIKE '%star%';', where LIKE is used for pattern matching and the percent signs (%) represent wildcard characters.

Step-by-step explanation:

The correct SQL statement to select movies with the word 'star' somewhere in the title is:

SELECT * FROM movies WHERE title LIKE '%star%'

Option A is correct because the LIKE clause is used in SQL for pattern matching. The percent signs (%) represent wildcard characters that substitute for zero or more characters. This allows the SQL query to match any titles that contain the word 'star' anywhere in the title, regardless of what comes before or after it. Option B is incorrect because it searches for a title that equals 'star' exactly. Option C contains a pseudo-function 'CONTAINS', which is not standard SQL syntax. Option D is incorrect because 'BEGINS WITH' is also not a standard SQL operator and would not find titles with 'star' somewhere other than the beginning.

User Plopp
by
8.9k points

No related questions found