Inner join

Inner join

tomzolltomzoll Posts: 7Questions: 0Answers: 0
edited December 2012 in General
Hello. I want to use a inner join in my mysql query, so I modified my server_processing.php but it doesn't work:

[code]
<?php

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/

/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array('observations.id_observations', 'observations.date_added', 'observations.id_animal', 'observations.id_species', 'observations.id_city', 'species.polish', 'geo_city.name', 'group_sp.group_name');

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "observations.id_observations";

/* DB table to use */
$sTable = "observations";
$sJoin = "INNER JOIN species on observations.id_species=species.id
INNER JOIN geo_city on observations.id_city=geo_city.id
INNER JOIN group_sp on observations.id_animal=group_sp.group_symbol";

/* Database connection information */
$gaSql['user'] = "123";
$gaSql['password'] = "123";
$gaSql['db'] = "123";
$gaSql['server'] = "localhost";

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/

/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}

/*
* MySQL connection
*/
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) )
{
fatal_error( 'Could not open connection to server' );
}

if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
fatal_error( 'Could not select database ' );
}

/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}

/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);

while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]

This is the original mySql query:
"SELECT observations.id_observations, observations.date_added, observations.id_animal, observations.id_species, observations.id_city, species.polish, geo_city.name, group_sp.group_name
FROM observations
INNER JOIN species on observations.id_species=species.id
INNER JOIN geo_city on observations.id_city=geo_city.id
INNER JOIN group_sp on observations.id_animal=group_sp.group_symbol"

What I am doing wrong? Can you help me?

Greetings
Tom

Replies

  • tomzolltomzoll Posts: 7Questions: 0Answers: 0
    Does anyone have any ideas how resolve this problem ?
    Thanks
This discussion has been closed.