[sql]
SELECT DISTINCT site_users_plans.plan_id
FROM
site_users_plans as sup,
site_users_plans_features as supf1,
site_users_plans_features as supf2
WHERE
sup.plan_id = supf1.plan_id
AND
sup.plan_id = supf2.plan_id
AND
plan_type = 1
AND (supf1.feature_name = 'plan_os' AND supf1.feature_value = 'FreeBSD')
AND (supf2.feature_name = 'plan_server_software' AND supf2.feature_value = 'Apache')
[/sql]