| Index
» Projekty
» phpMyEdit
» Fórum
» JOIN frustration |
 |
angst
Založený: 12.04.2010
Príspevky: 1
Zaslal: 2010-04-12 07:21
Návrat hore
Odpovedať s citátom
|
I know this should be easy but for some reason my joins are failing.
I have two tables:
$join_table = 'cwb_listingmeta'; // alias of the values table
$main_table = 'cwb_listing'; // alias of the main table
$join_column = 'cwb_listingid';
$main_column = 'cwb_listingid';
$opts['fdd']['cwb_id'] = array(
'name' => 'Cwb ID',
'select' => 'T',
'options' => 'AVCPR', // auto increment
'maxlen' => 11,
'default' => '0',
'sort' => true
);
$opts['fdd']['cwb_listingid'] = array(
'name' => 'Listing Id',
'select' => 'T',
'maxlen' => 10,
'sort' => true
);
$opts['fdd']['cwb_baseprice'] = array(
'name' => 'Base Price',
'select' => 'T',
'maxlen' => 30,
'sort' => true,
'join' => $main_table.$main_column = $join_table.$join_column
);
I want to list the value from the cwb_baseprice column from the join table where the joined tables cwb_listingid matches.
cwb_id,cwb_listingid columns are in the cwb_listing table and cwb_listingid, cwb_baseprice columns are in the cwb_listingmeta table.
|
kally
Založený: 05.01.2005
Príspevky: 14
Zaslal: 2010-05-05 19:18
Návrat hore
Odpovedať s citátom
|
Try using sql. Maybe this will head you on the right track:
| Kód: |
$opts['fdd']['virtual'] = array(
'name' => 'Base Price',
'input' => 'R',
'sort' => true,
'sql' => "(SELECT a.cwb_baseprice FROM ".$join_table." as a, ".$main_table." as b WHERE b.cwb_listingid LIKE PMEtable0.cwb_listingid )"
);
|
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|