TAG 2000591, WHERE clause

Write a query that displays all songs whose names have at least three words.


My Code:
FROM track
WHERE LENGTH(‘name’) >= 3;

What I expected to happen: the songs with titles longer than 3 words be be produced

What actually happened: all song titles were produced

I do not understand how to use greater/lesser than with text columns.

Hi @ariisintech:

Length returns the number of characters and not the number of words. To do so, you may need a more complex query, somewhat like this.

Thank you for that answer. The results for the link were not helpful to the question though as they didn’t populate the table correctly ( though even if they did, since the code was different it would’ve been flagged as wrong). I will be sure to check stack overflow in the future though, thank you again.

Screen Shot 2021-05-29 at 7.54.21 am

Hey, I just had same question and solved, hope it can help you.
My idea was ‘3 words must have at least 2 space’
Here is my code, hope it does help.