title: Is it possible to concat strings in SOQL?
body: <p>I've read thread from 2005 and people said SOQL does not support string concatenation.</p>
  
  <p>Though wondering if it is supported and someone has done this.</p>
  
  <p>I'm trying to concat but no luck :(</p>
  
  <p>Below is APEX code trying to find record with specified email.</p>
  
  <pre><code>String myEmail = 'my@email.com';
  String foo = 'SELECT emailTo__c, source__c FROM EmailLog__c 
                WHERE source__c = \'' +
                myEmail + '\';
  
  Database.query(foo)
  </code></pre>
  
  <p>Even though the record is indeed in the database, it does not query anything. Debug shows
  "row(0)" which means empty is returned.</p>
  
  <p>Am I doing concat wrong way?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I just found a way not have to add single quote. Just needed to apply same colon variable even for String that has query.</p>
  
  <pre><code>String foo = DateTime.newInstance(......);
  
  String bar = 'SELECT id FROM SomeObject__c WHERE createdOn__c = :foo';
  
  List&lt;SomeObject__c&gt; result = Database.query(bar);
  
  System.debug(result);
  </code></pre>
  
  <p>This works too and is necessary if WHERE clause contains DateTime since DateTime cannot be surrounded with single quotes.</p>