Given a table rules
rule_id = 1
rule_condition = 'size > 15'
how can I run a query like this
SELECT * FROM rawdata where (Select rule_condition FROM rules WHERE rule_id=1)
Is the only way to do it a stored procedure like this: mysql – query inside a query
This is essential reading for you before starting with dynamic SQL
For SQL Server you would use something like…
Hopefully you are not planning on allowing users to enter arbitrary
rule_conditions as they could execute any arbitrary statements against your SQL Server.