I have a query that contains a UNION operator. If I ran my query it runs perfectly straight on the database but I am getting an empty result in Drupal.
Here is a simplified version of the query:
$result = db_query("
SELECT *
FROM (
SELECT
agent_number
FROM table1
WHERE agent_number IN (':agent_numbers')
UNION
SELECT
agent_number
FROM table2
WHERE agent_number IN (':agent_numbers')) t", array(
':agent_numbers' => $agent_ids,
)
)->fetchAll();
Is it that db_query()
doesn't support UNION?