Reputation: 39
hI I Want to wrap the following mysql queries into one in my php file.
the first is:
$query = 'SELECT cat_name FROM #__tt_cats WHERE cat_published = 1 AND cat_name LIKE ' . $db->quote('%'.$q.'%');
and the second is:
$query = 'SELECT link_name FROM #__tt_links WHERE link_name LIKE ' . $db- >quote('%'.$q.'%');
How can i do this ???
Upvotes: 0
Views: 61
Reputation: 11047
Check Union
$query = 'SELECT cat_name FROM #__tt_cats WHERE cat_published = 1 AND cat_name LIKE ' . $db->quote('%'.$q.'%')
$query += ' UNION '
$query += 'SELECT link_name FROM #__tt_links WHERE link_name LIKE ' . $db- >quote('%'.$q.'%');
The UNION operator selects only distinct values by default. To allow duplicate values, use the ALL keyword with UNION.
Upvotes: 2