You need to sign in to do that
Don't have an account?

Concatinate function in SOQL
Hi,
What should be the query to cancatinate two fields in SOQL
The equivalent mysql query is
select id from User where concat(firstname," ",lastname)="Hari G S";
Thanks and Regards
Hari G S
There is nothing like concat function in SOQL.
If you are querying on the user object to retrieve the first name and last name values by appending, then you can use the standard name field on user. The query looks like this:
User u = [select id, name from user where name='hari gs'];
All Answers
Use this way:
soql='SELECT Id,Name,Alias_Company_Name__c,Office_Country__c, Office_State__c, Prospect_Of__c,Client_Of__c FROM Account where Name != null';
//Some Code...
soql+= 'order by '+ sortfield + ' ' + sortDir;
then use
results = Database.query(soql);
sortfield is a variable defined in the controller...
Thanks for the reply.
But i actualy want to know whether there is any function like concat in SOQL to concatinate two fields, not appending query string using + operator.
In user object we have fields firstname and lastname. firstname is hari and lastname is gs. I want to check whether hari gs is present in the user object combining these two fields. The logic in mysql query is below
select id from user where concat(firstname," ",lastname)="hari gs";
Regards
Hari
There is nothing like concat function in SOQL.
If you are querying on the user object to retrieve the first name and last name values by appending, then you can use the standard name field on user. The query looks like this:
User u = [select id, name from user where name='hari gs'];