0

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

Edited by aneeka: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by urtrivedi
0

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";
0

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('');
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.