Jump to content


Database: tables Join

Recommended Posts

Have error in this script in Application system. I have 2 records in array if have record in table news_upload.

$select = \IPS\Db::i()->select( '*', 'news_news', NULL, 'news_artcms_news.num DESC', array( 0, 25 ) );
$select = $select->join( 'news_uploads', 'news_uploads.recordNum=news_news.num', 'LEFT' );
$results = \IPS\Db::i()->query($select);

Where is my mistake?

Next code work Ok in block system. 

$select = $connection->select( '*', 'news_news', NULL, 'news_news.num DESC', array( 0, 25 ) );
$select = $select->forceIndex( 'num' ); 
$select = $select->setKeyField( 'num' );
$select = $select->join( 'news_uploads', 'news_uploads.recordNum=news_news.num', 'LEFT' );
$results = \count($select); 

But in application system I have error for forceIndex() and setKeyField.

Think what problem because tables have field 'num', and select get this from second table, but I have to get it from first....

Possible using distinct can decide this task, but can not find sintax.

Edited by Bazilisk
Link to comment
Share on other sites


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy