You need to sign in to do that
Don't have an account?
Hardik Baldania 4
Querying 2 unrelated custom objects in a single query.
Hello,
I have a situation in which I have to run a single query from 2 differenct unrelated custom objects and I actually have no clue how to do that in SOQL, as SOQL doesn't have the JOIN functionality.
I have 2 Custom Object named: 1. jud_city_list__c and 2. jud_dlr_list__c.
This is the SQL query which I want to access through SOQL.
SELECT `l`.`city`, `l`.`pref_dlr1`, `l`.`pref_dlr2`, `l`.`pref_dlr3`, `d`.`name`, `d`.`dlrid`, `d`.`state`
AS `dlr_states`, `d`.`city` AS `dlr_city`, `d`.`ud_dlrid`
FROM `jud_city_list` `l`JOIN `jud_dlr_list` `d` ON `d`.`dlrid` IN (l.pref_dlr1,l.pref_dlr2,l.pref_dlr3)
WHERE `l`.`city` LIKE 'm%' ESCAPE '!'ORDER BY `l`.`city` ASC
where l - jub_city_list__c object
d - jub_dlr_list__c object.
I don't know how to get this SQL query into SOQL query. Do I have to write a wrapper class for this ? Or Is there any other possible way available to get this query written into SOQL ?
Thanks you so much in advance, looking for some serious help.
Regards,
Hardik B.
I have a situation in which I have to run a single query from 2 differenct unrelated custom objects and I actually have no clue how to do that in SOQL, as SOQL doesn't have the JOIN functionality.
I have 2 Custom Object named: 1. jud_city_list__c and 2. jud_dlr_list__c.
This is the SQL query which I want to access through SOQL.
SELECT `l`.`city`, `l`.`pref_dlr1`, `l`.`pref_dlr2`, `l`.`pref_dlr3`, `d`.`name`, `d`.`dlrid`, `d`.`state`
AS `dlr_states`, `d`.`city` AS `dlr_city`, `d`.`ud_dlrid`
FROM `jud_city_list` `l`JOIN `jud_dlr_list` `d` ON `d`.`dlrid` IN (l.pref_dlr1,l.pref_dlr2,l.pref_dlr3)
WHERE `l`.`city` LIKE 'm%' ESCAPE '!'ORDER BY `l`.`city` ASC
where l - jub_city_list__c object
d - jub_dlr_list__c object.
I don't know how to get this SQL query into SOQL query. Do I have to write a wrapper class for this ? Or Is there any other possible way available to get this query written into SOQL ?
Thanks you so much in advance, looking for some serious help.
Regards,
Hardik B.
Please choose it as the Best answer, if you find it helpful .
May be you can query both object seperately by using 2 lists and then use wrapper to put both unrelated objects data in single list.
Thanks
Arpit