datatables.net을 사용하고 있지만 중첩 쿼리 및 조인 작동 방법을 찾기 위해 고심하고 있습니다. 나는 그저 어떤 예제를 찾는 것 같지 않습니다.Datatables - 중첩 된 SELECT 및 조인
// DB table to use
$table = 'support_msgs';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array('db' => 'id', 'dt' => 0),
array('db' => 'user_id', 'dt' => 1),
array('db' => 'title', 'dt' => 2),
array('db' => 'msg', 'dt' => 3),
array('db' => 'date', 'dt' => 4)
);
// SQL server connection information
$sql_details = array(
'user' => 'user',
'pass' => 'pass',
'db' => 'db',
'host' => 'localhost'
);
require('ssp.class.php');
// echo json_encode(
// SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
//);
echo json_encode(
SSP::complex($_GET, $sql_details, $table, $primaryKey, $columns)
);
을하지만 지금,이 질의를하고 난 이것에 대한 올바른 방향으로 날 가리 할 수있는 모든 작업을 볼 수 없습니다 : 나는 (다른 테이블의 경우)가 같은 것을 사용하여 간단한 쿼리를 보여 얻을 수 있습니다 :
SELECT
vp.id,
vp.post_title,
(
SELECT
vpm.meta_value
FROM
vhyky_postmeta vpm
WHERE vp.id = vpm.post_id
AND vpm.meta_key = 'cs_cause_goal_amount'
) AS Bonus,
(
SELECT
vpm.meta_value
FROM
vhyky_postmeta vpm
WHERE vp.id = vpm.post_id
AND vpm.meta_key = 'cs_cause_raised_amount'
) AS Deposit,
wt.name,
vp.post_content
FROM
vhyky_posts vp,
vhyky_postmeta vpm,
vhyky_term_relationships wtr,
vhyky_term_taxonomy wtt,
vhyky_terms wt
WHERE vp.post_type = 'cs_cause'
AND vp.post_status = 'publish'
AND vp.id = vpm.post_id
AND vp.id = wtr.object_id
AND wtr.term_taxonomy_id = wtt.term_taxonomy_id
AND wt.term_id = wtt.term_id
AND wtt.term_id = '114'
group by vp.id