Jump to content

Recommended Posts

So basically i'm pulling data from two tables where both tables have a commong field.

filenumber in employee_directory is equal to dognet_user_id in mvx.phone_history_io.

 

I ran a small simple query to test the php, and it worked fine, so there's something wrong with this query and i cant seem to understand what. I dont get any errors, i simply dont get a result. And i dont know if it's the mysql part or the php part of it that im having issues with.

 

Here's the query i run.

 

<?php
$sql_1 = "SELECT employee_directory.filenumber, 
                 employee_directory.phone, 
                 employee_directory.firstname, 
                 employee_directory.lastname, 
                 employee_directory.managerid, 
                 employee_directory.departmentid, 
                 employee_directory.branchid, 
                 pcsmgr.mvx_phone_history_io.extension, 
                 pcsmgr.mvx_phone_history_io.calldate, 
                 pcsmgr.mvx_phone_history_io.calltype, 
                 pcsmgr.mvx_phone_history_io.dur_seconds, 
                 pcsmgr.mvx_phone_history_io.dur_minutes, 
                 pcsmgr.mvx_phone_history_io.dist_pnums, 
                 pcsmgr.mvx_phone_history_io.count_pnums, 
                 pcsmgr.mvx_phone_history_io.dognet_user_id, 
                 pcsmgr.mvx_phone_history_io.callcat
          FROM   employee_directory, pcsmgr.mvx_phone_history_io
          WHERE  employee_directory.managerid = '$DT_filenumber' AND
                 employee_directory.branchid = '$branchid_SQL' AND
                 pcsmgr.mvx_phone_history_io.calldate BETWEEN '$sDate' AND '$eDate' AND
                 employee_directory.filenumber = pcsmgr.mvx_phone_history_io.dognet_user_id 
                 ORDER BY employee_directory.firstname ASC";
$go_1 = oci_parse($conn, $sql_1);
oci_execute($go_1);

if($result_1 = oci_fetch_assoc($go_1))
    { echo "GOOD"; }
else
    { echo "BAD"; } // THIS KEEPS SHOWING UP

?>

 

Thanks for the help!

Link to comment
https://forums.phpfreaks.com/topic/183855-whats-wrong-with-my-query/
Share on other sites

Ok i've figured out what causes the issue. It's this line....

AND
employee_directory.filenumber = pcsmgr.mvx_phone_history_io.dognet_user_id

 

My guess is that it's beacuse of the pcsmgr. i guess two dots is too many LOL.

But i have to use this because that table is in a different schema on the database.

 

Any ideas?

I also tried using an alias for the table, but still i get "BAD" as result.

 

<?php
$sql_1 = "SELECT EmpDir.filenumber, 
			 EmpDir.firstname, 
			 EmpDir.lastname, 
			 EmpDir.managerid, 
			 EmpDir.departmentid, 
			 EmpDir.branchid, 
			 MVX.extension, 
			 MVX.calldate, 
			 MVX.calltype, 
			 MVX.callcat,
			 MVX.dur_seconds, 
			 MVX.dur_minutes, 
			 MVX.dist_pnums, 
			 MVX.count_pnums, 
			 MVX.dognet_user_id
	  FROM   employee_directory EmpDir, pcsmgr.mvx_phone_history_io MVX
	  WHERE  EmpDir.managerid = '$DT_filenumber' AND
			 EmpDir.branchid = '$branchid_SQL' AND
			 MVX.calldate BETWEEN '$sDate' AND '$eDate' AND
			 EmpDir.filenumber = MVX.dognet_user_id
			 ORDER BY EmpDir.firstname ASC";
$go_1 = oci_parse($conn, $sql_1);
oci_execute($go_1);

if($result_1 = oci_fetch_assoc($go_1))
{ echo "GOOD"; }
else
{ echo "BAD"; } // STILL GET THIS
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.