Create query based on keywords from database

I have a $ccl_query variable which looks like this

$ccl_query = "(ayw = ".$keyword[$i].") and ((ayw = kids) or (ayw = youth) or (ayw = playground) or (ayw = game) or (ayw = little kids))";

This variable is in my search function, which performs a search based on this query.

$keyword[$i] is some keyword from an array of keywords, and I iterate in search function until I go through all keywords.

As you can see, second part of $ccl_query is filled with static data and thats what I want to change. I want it to be loaded from database and used the exactly same way as it is now, meaning I don't want to iterate and perform a search with ayw = keyword[i] AND ayw = term1, ayw = keyword[i] AND ayw = term2 ...

I want it to be as it is now with static data e.g. ayw = keyword[i] AND ((ayw = term1) OR (ayw = term2) OR ... )

How can I load all of those terms at once into $ccl_query?