Is DataTable possible to represent queries from multiple tables?

Is DataTable possible to represent queries from multiple tables?

DenonthDenonth Posts: 76Questions: 0Answers: 0
edited June 2012 in General
Hi all,

Can somone give me a example if it is possible to represent data from multiple tables into a one table?

Replies

  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    Yes, all you would need to do is add the appropriate join(s) to the query from one of the server side examples: http://datatables.net/development/server-side
  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    Yea I think I need to do join, am I allowed to change $sWhere variable as it is set on "" . And I would like to put my join part here. Or I need to put join part in $sTable variable?
  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    If you're using the PHP/MySQL example here:

    http://datatables.net/development/server-side/php_mysql

    starting at line 123:

    [code]
    $sQuery = "
    SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
    FROM $sTable
    $sWhere
    $sOrder
    $sLimit
    ";
    [/code]

    and change it to something like:

    [code]
    $sJoin = ' JOIN myable on mytable.id = myothertable.id ';
    $sQuery = "
    SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
    FROM $sTable
    $sJoin
    $sWhere
    $sOrder
    $sLimit
    ";
    [/code]
This discussion has been closed.