Reputation: 4077
What is the best way of fetching data from two tables on an ajax source?
I am using datables like:
$('#user_types').dataTable({
'bServerSide' : true,
'bProcessing' : true,
'sAjaxSource' : 'datatables/ajax_file.php',
'iDisplayLength' : 50,
"sPaginationType": "bootstrap",
"oLanguage":{
"sSearch": "",
"sLengthMenu": "Limit: _MENU_"
},
'aaSorting': [[3, 'desc']],
'aoColumns' : [
null,
null,
null,
null,
null,
null,
null,
{'bSortable' : false},
]
})
Now, on ajax_file.php, I am reading all the info from one table. Now I need to get a column from another table, how can I do so?
Upvotes: 0
Views: 488
Reputation: 21856
Change the query in your datatables/ajax_file.php
from a 'normal' select query into a query with a JOIN
or UNION
, joining the tables you want to display together.
Upvotes: 1