I am trying to search and filter by two different databases.
DATABASE1.table1 | DATABASE2.table1
id | col2 | id | ref_col2 | ref_col3
1 | 2 | 1 | thing | thing
2 | 500 | 2 | other | other
I know you can use the following if its on the same database:
$search = explode(" ", mysqli_real_escape_string($connection, $_POST["search_string"]));
$search_string = " AND (";
for($i=0;$i<count($search);$i++){
$search_string .= "(t2.ref_col2 LIKE '%".$search[$i]."%' OR t2.ref_col3 LIKE '%".$search[$i]."%') AND ";}
$search_string = substr($search_string,0,strlen($search_string)-4);
$search_string .= ")";
$query = mysqli_query($connection, "SELECT t1.*, t2.* AS row_count FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t1.id = t2.id WHERE t1.id>0".$search_string)or die();
My question is: What if they are on two different databases? is there a specific way to select one database.table results by searching another database.table's list the above?