0

I need to retrieve the banners_clients data only when exists banners for this client id:

Example:

banner one - client id 1

banner two - client id 1

banner three - client id 4

client id 1 - name John

client id 2 - name Lucy

client id 3 - name Holga

client id 4 - name Jorge

---- after fetch data ---

client id 1 - name John

client id 4 - name Jorge

https://pastebin.com/UCMrRT72

2 Answers 2

1

Join the banners table.

$query->select($db->quoteName(array('a.id','a.name','contact','email','extrainfo','state','checked_out','checked_out_time','metakey','own_prefix','metakey_prefix','purchase_type','track_clicks','track_impressions')));
$query->from('#__banner_clients a')
  ->join('inner', '#__banners b ON b.client_id = a.id');
2
  • Table 'carrosde_newclass.#__banner_clients a' doesn't exist Commented Dec 19, 2017 at 17:05
  • Please see my edited code
    – Nagarjun
    Commented Dec 21, 2017 at 15:27
0

Solved:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.*');
$query->from($db->quoteName('#__banner_clients', 'a'))
->join('INNER', $db->quoteName('#__banners', 'b') . ' ON (' . $db->quoteName('b.cid') . ' = ' . $db->quoteName('a.id') . ')')
->order($db->quoteName('a.name') . 'ASC');
$db->setQuery($query);
$results = $db->loadObjectList();
1
  • If this is the solution that you implemented, please mark your answer with the green tick. This will prevent the system from bumping this page to the top of the questions list for new volunteer attention. Commented Mar 12, 2019 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.