I have a table where one of the columns contains text, for which I count the words:
SELECT SUM( LENGTH(`text`) - LENGTH(REPLACE(`text`, ' ', ''))+1) AS length
FROM tblParadigm WHERE `uuid`=$uuid;
So that I can filter rows which have below or above a certain count of words. Now I can select random rows from this table, using:
SELECT `uuid` FROM tblParadigm ORDER BY RAND() LIMIT 10;
My Question is, how can I combine those two, in order to select 10 random rows, which have a word count of less than $count
?
Do I need a JOIN
or an IF
? I would prefer to do this in MySQL rather than PHP.
You may want to use the MySQL HAVING clause at the end of your first query.
Having length < 5