You need to sign in to do that
Don't have an account?
Team Works
Database.Query -- How to concaenate this SOQL as string
I want to concatenate two strings to for the query to be executed using Database.Query. Here is what i am doing
string sql1 = 'Select Custom_Name__c from Opportunity where AccountId IN';
string2 sql2= '(Select Id from Account where Europe__c =True)';
Opp=Database.query(sql1+sql2);
sysem.debug(Opp);
Doesn't work.Any Ideas?
string sql1 = 'Select Custom_Name__c from Opportunity where AccountId IN';
string2 sql2= '(Select Id from Account where Europe__c =True)';
Opp=Database.query(sql1+sql2);
sysem.debug(Opp);
Doesn't work.Any Ideas?
not sure what exactly your requirments are.. and why you need dynamic soql for this.. but you can try the below code..
All Answers
private final String SOQL_START_FUNDS = 'SELECT Id,Name FROM Account';
List<Account> result = Database.Query(SOQL_START_FUNDS + ' WHERE Id IN :ListofIds\''); //Does't work
Need Help!!
not sure what exactly your requirments are.. and why you need dynamic soql for this.. but you can try the below code..
Again Stuck with the concatenation :
private final String SOQL_RECENT_REC = 'SELECT LastViewedDate,Type,UserRoleId FROM RecentlyViewed';
private final String CONDITION_USER_SORT = ' Order By LastViewedDate DESC LIMIT 20';
List<RecentlyViewed> recentViewed= new List<RecentlyViewed>();
recentViewed = Database.query(SOQL_RECENT_REC +' WHERE Type = \'Account \' ' + CONDITION_USER_SORT);
Should run a query like the following :
recentViewed = [SELECT LastViewedDate,Type,UserRoleId FROM RecentlyViewed Where Type='Account' Order By LastViewedDate DESC LIMIT 20];
Many Thanks !!