6

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
  • 1
    I guess its better to create formula field and use that instead in query Jun 2, 2014 at 5:36

2 Answers 2

11

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.

4

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 .

You must log in to answer this question.

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