I want to get random row from database, but limit it using some content.
For example, table's definition:
id | content | tags
The query is: SELECT * FROM tbl ORDER BY RAND() LIMIT 1
.
Tags part looks like: tag1, tag2, tag42
. So, for example, I want one random row from ones which have tag42
or tag2
inside tags
.
Some pseudocode:
SELECT * FROM tbl ORDER BY RAND() WHERE tags LIKE '%tag42%' OR '%tags2%' LIMIT 1
.