Hi All,
I’m trying to add an AND clause to a UNION query but unsure of what the syntax should be.
Here is my UNION as is:
$result = mysqli_query($link,
"(SELECT * FROM table_1 WHERE MATCH($field1) AGAINST('$keyword1*' IN BOOLEAN MODE))
UNION
(SELECT * FROM table_2 WHERE MATCH($field2) AGAINST('$keyword2*' IN BOOLEAN MODE))");
What I want to do is add an additional AND clause to both so:
$result = mysqli_query($link,
"(SELECT * FROM table_1 WHERE MATCH($field1) AGAINST('$keyword1*' IN BOOLEAN MODE) AND MATCH($field2) AGAINST($array_selection))
UNION
(SELECT * FROM table_2 WHERE MATCH($field2) AGAINST('$keyword2*' IN BOOLEAN MODE) AND MATCH($field2) AGAINST($array_selection))");
Is this AND addition correct? Or, do I need to group the UNION, then supply an AND clause? Nothing is working quite yet…
Thanks!