I'm new to using PDO to make db requests and need a little help. I have the following db call:
$stmt1 = $pdo->prepare('
SELECT * FROM news WHERE pub_date >= ? AND pub_date < ? AND display = 1 ORDER BY pub_date DESC
UNION
SELECT * FROM vs_news WHERE pub_date >= ? AND pub_date < ? AND display = 1 ORDER BY pub_date DESC
');
$stmt1->bindParam(1, $col_start);
$stmt1->bindParam(2, $col_end);
$stmt1->execute();
I have read enough to think the UNION is compatable with PDO, but I can't seem to get the code right and can't find an example in complete code format.
The fields in both tables are the same and the db call works with just one or the other table, but not with the UNIION that I have shown.
Could someone please point where my problem is?
Thanks