Jafo
Jafo

Reputation: 1331

MySQL Select Column With X Words

I am trying to come up with a query that will select a row if a column has at least X words in it. For example:

SELECT * FROM TABLE IF COLUMN <has >= 3 words>

Coming up empty though. Any ideas?

Upvotes: 2

Views: 60

Answers (1)

juergen d
juergen d

Reputation: 204784

3 words need at least 2 spaces. You can count the spaces in your column

select * from your_table
where length(your_column) - length(replace(your_column, ' ', '')) > 1

Upvotes: 5

Related Questions