How can I join MySQL tables from different databases when the only similar field is the primary key of the first table in Php?

select * from db1.table1 a left outer jion db2.table2 b on a.joincolname=b.joincolname

I have this code and it displays nothing..is this possible?

$query = mysql_query("SELECT COUNT (*) from timerecord.timesheet.fnempid, timerecord.timesheet.fdDate, timerecord.timesheet.fnDepid, timerecord.timesheet.fnDivId, timerecord.timesheet.ftTimeIn, timerecord.timesheet.ftTimeOut, timerecord.timesheet.fcEmpName, timerecord.timesheet.fcRemarks, Master.refdepartment.fcDeptDesc FROM timerecord.timesheet inner join Master.refdepartment on timerecord.timesheet.fnDepid = Master.refdepartment.fnDeptId where timerecord.timesheet.fdDate = '$date' AND timerecord.timesheet.ftTimeIn != '' AND timerecord.timesheet.fcDeptDesc like '$dept'")or die(mysql_error());
			$result_query = mysql_result($query,0,0); 
			echo "Total: $result_query";

You first output your query before executing, then copy that query to mysql admin panel, may be mysql client or query browser or phpmyadmin ,what ever you have. Then see the result, is it coming there as expected.

$query="SELECT COUNT (*) from timerecord.timesheet.fnempid, timerecord.timesheet.fdDate, timerecord.timesheet.fnDepid, timerecord.timesheet.fnDivId, timerecord.timesheet.ftTimeIn, timerecord.timesheet.ftTimeOut, timerecord.timesheet.fcEmpName, timerecord.timesheet.fcRemarks, Master.refdepartment.fcDeptDesc FROM timerecord.timesheet inner join Master.refdepartment on timerecord.timesheet.fnDepid = Master.refdepartment.fnDeptId where timerecord.timesheet.fdDate = '$date' AND timerecord.timesheet.ftTimeIn != '' AND timerecord.timesheet.fcDeptDesc like '$dept'";
echo $query;
die('');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.