I am trying to run SOQL statement in salesforce.schema tool of FORCE.COM the following query:

Select c.LastName, c.FirstName From Contact c
WHERE (FirstName+' '+LastName) In ('Good Name','Bad Name')

It produces an error.

Can I do this kind of things with SOQL ? If yes, then how I can concatenate fields in the query ?

  • 1
    I guess its better to create formula field and use that instead in query Commented Jun 2, 2014 at 5:36

3 Answers 3


SOQL does not support concatenation operation like SQL.

But here is work around for you.

Select c.LastName, c.FirstName From Contact c WHERE name In ('Good Name','Bad Name')

If above soql is for sample and you want to use this on some other fields then you can create formula field that will concatenate two fields and use that in your SOQL.


So the answer is no rightaway .There is no concatenation function in SOQL.

The best is to create a formula field and use the same in your query or why dont you use Name field of contact directly .

Name field is anyways concatenation of FirstName and LastName .


This worked for me in 2024:

SELECT FirstName, LastName
FROM Contact
WHERE CONCAT(FirstName,' ',LastName) IN ('Good Name','Bad Name')

  • Where have you used this successfully? In SOQL? It doesn't work. SOQL is not some special SQL. Commented Feb 7 at 22:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .