I am trying to retrieve data from db with INNER JOIN.
I need the following query executed from drupal's db_select()
, query is in normal format :
SELECT uo.* , uop.data FROM `uc_orders` AS uo
INNER JOIN `uc_order_products` AS uop ON uo.order_id = uop.order_id
WHERE (
(
uop.data LIKE '%mfp_donation%'
)
OR (
uop.data LIKE '%scholar_donation%'
)
OR (
uop.data LIKE '%reunion%'
)
)
I already tried in drupal, the process is following :
$query = db_select('uc_orders', 'uo')
->fields('uo')
->fields('uop', array('data'));
$alias = $query->join('uc_order_products', 'uop', "uo.order_id = uop.order_id");
$order = $query->condition(db_or()
->condition($alias . '.data', '%mfp_donaiton%', 'LIKE')
->condition($alias . '.data', '%scholar_donaiton%', 'LIKE')
->condition($alias . '.data', '%reunion%', 'LIKE')
)
->execute()
->fetchObject();
All the process is working fine, but the problem is when i execute/fetch the results then i only get the output for ->condition($alias . '.data', '%reunion%', 'LIKE')
. I mean i only get the %reunion%
part. The first two conditions is not executing i think.
Any suggestion?