I have a database join field with a WHERE condition in Fabrik. The field gets its content from tableA. The WHERE condition needs one variable from the URL {queryParam}.

This is the WHERE condition:

WHERE EXISTS (SELECT 1 FROM tableB WHERE {thistable}.id = tableB.selected AND tableB.parent_id = {queryParam})

The issue with this is, that queryParam of course is not always defined which then breaks the whole application since the SQL query is invalid.

I'm not very familiar with Fabrik and Joomla. What would a good practice be to handle this issue? I know, that without queryParam the SQL query will always return nothing. Is there a way to check if queryParam is set and If it's not to prevent the SQL query from running?

Or can I set a default for queryParam (e.g 0, which also will always lead to no results)

I've already looked through the Fabrik wiki, forum and Joomla posts but couldn't find any useful information.

Environment: Joomla 3.9.4, Fabrik 3.x

  • Thanks for posting here. Please take our tour. Feb 11, 2021 at 22:57

1 Answer 1


I managed to solve this by wrapping the queryParam with quotes und then comparing it with an empty string.

WHERE EXISTS (SELECT 1 FROM tableB WHERE {thistable}.id = tableB.selected AND IF('{queryParam}' = '', true, tableB.parent_id = '{queryParam}'))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.