IgnitedDatatables / Ignited-Datatables

Ignited Datatables is a wrapper class/library based on the native Datatables server-side implementation by Allan Jardine found at http://datatables.net/examples/data_sources/server_side.html for CodeIgniter
285 stars 335 forks source link

table join (alias issues) #98

Closed marikudo closed 6 years ago

marikudo commented 9 years ago

Hi,

have a problem when joining two or more tables with alias $db['default']['dbprefix'] = 'tbl_';

here's my query $this->datatables->select('user_id,role_id,email,password,first_name,last_name,position,u.fsp_unique_id,u.updated_at,u.status,f.fsp_unique_id,f.fsp_name') ->from('users AS u') ->join('fsp AS f','u.fsp_unique_id = f.fsp_unique_id'); echo $this->datatables->generate();

and the output error is this

Error Number: 1054 Unknown column 'tbl_u.fsp_unique_id' in 'on clause' SELECT COUNT(*) AS numrows FROM (tbl_users AS u) JOIN tbl_fsp as f ON tbl_u.fsp_unique_id = f.fsp_unique_id

please help how to fix this, Thank in advance.

iMezied commented 7 years ago

generate "view" in database that have the join query and select from "view"