Okay I'm going to try to answer this as best as I can given the question.
First you probably don't need to loop that query over the results. You need to add those results to a comma separated string or something of that nature and input them into your SQL statement using IN
Note:I'm not even going to bother going into exists with this question so don't ask question viewers.
Second you DO NOT want to use a HAVING
clause in this situation as it applies the filter after gathering all the results. For performance this sucks on ice and is not something you want to do. So applying these two fixes makes you solution look like this.
SELECT
form_validator.id as validator_id,
form_validator.`name` as validator_name,
form_filter.id as filter_id,
form_filter.`name` as filter_name,
form_field_has_form_validator.form_field_id,
form_field_has_form_validator.form_validator_id,
form_field_has_form_validator.`options` as validator_options
FROM form_field
INNER JOIN form_field_has_form_filter
ON form_field_has_form_filter.form_field_id = form_field.id
INNER JOIN form_field_has_form_validator
ON form_field_has_form_validator.form_field_id = form_field.id
INNER JOIN form_filter
ON form_field_has_form_filter.form_filter_id = form_filter.id
INNER JOIN form_validator
ON form_field_has_form_validator.form_validator_id = form_validator.id
WHERE form_field.form_field_id IN (YourCommaSeperatedValueList)
Next lets talk formatting. Since the table names are a bit messy we are going to use aliasing to make it easier to read. This should help with you WHERE
clause error you mentioned in the comments as well.
SELECT
FV.id as validator_id,
FV.`name` as validator_name,
FF.id as filter_id,
FF.`name` as filter_name,
FFV.form_field_id,
FFV.form_validator_id,
FFV.`options` as validator_options
FROM form_field as F
INNER JOIN form_field_has_form_filter FH
ON FH.form_field_id = F.id
INNER JOIN form_field_has_form_validator FFV.
ON FFV..form_field_id = F.id
INNER JOIN form_filter FF
ON FH.form_filter_id = FF.id
INNER JOIN form_validator AS FV
ON FFV.form_validator_id = FV.id
WHERE F.form_field_id IN (YourCommaSeperatedValueList)
There that looks much better and now your WHERE
clause is easier to get right because you don't have overlapping column names.
Now last but not least find the person who name those tables and punch them directly in the face.