How to gain data from two separate tables?

How to gain data from two separate tables?

BradleyO07BradleyO07 Posts: 11Questions: 8Answers: 0

I am currently running a piece of code that will display data from one data table. I need to get data from another table as well thats in another database but on the same server. Currently this is my code to extract data:

$db = "MFG-ERP";
$dbRecipe = "MFG-RECIPE";

function getResinData($sdate, $fdate){
  global $db;
  global $dbRecipe;

  $start = $sdate . ' 07:00:00';
  $finish = $fdate . ' 07:00:00';

  $current_query_string = "SELECT a.sequence_no, a.sample_datetime, a.start_end, a.item, 
a.erp_update, a.wip_entity_name, a.shift, a.nc334_to_mix, a.nc371_to_mix, b.recipe 
FROM sigma1 a JOIN sigmatransstd b ON a.item=b.recipe 
WHERE a.sample_datetime >= '$start' AND a.sample_datetime < '$finish' 
AND a.note IS NULL ORDER BY a.sequence_no ASC";

  $result = basicQuery($current_query_string, $db);

  $data = create_resin_table_data($result);

  return $data;

}

When I run the code i get a JSON error and the response tab says that "Table 'MFG-ERP.sigmatransstd' does not exist. Table sigmatransstd is in MFG-RECIPE. How could I rewrite my code to show that the table in in MFG-RECIPE?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,313Questions: 26Answers: 4,771
    Answer ✓

    Sounds like your question is more about SQL rather than a Datatables specific question. Stack Overflow is a good place to look for SQL type questions. Maybe this thread will help.

    Kevin

Sign In or Register to comment.