I am trying to figure out the best way to do multiple LIKE matches in a complicated soql statement.   I want to change the hubFilter value from just "BCS%" to "BCS%,Benefit Advisor,Mgr of Ben,BSR".  I tried this and got nothing back so I assume it's not reading those as separate values. Any ideas?  Here is a basic example of what my query looks like:  list&lt;BCS__c&gt;hubs = new list&lt;BCS__c&gt;(); private string hubfilter; if(showAll == TRUE){     hubFilter = '%'; }else{     hubFilter = 'BCS%'; } hubs = [     SELECT /*fields and subqueries*/ FROM BCS__c     WHERE /*other clauses*/ AND Title__c LIKE :hubFilter ];
63457
Is there a way to mix LIKE operator with IN ? Something Like  SELECT Id FROM Account WHERE Name LIKE IN:nameList   Where nameList is list of String? Is this is possible ? (I can make a dynamic query by doing OR with all the elements, but was looking for a more elegant way to do this)
34626
the soql in the following code is failing. The error message is: "Compile failure on line 6, column 5: Unexpected token '&lt;'."   Map&lt;Id, String&gt; profileIds = new Map&lt;Id, String&gt;(); profileIds.put('00eee000000xxxx','System Administrator'); profileIds.put('00eee00000yyyyy','YYY Profile'); profileIds.put('00eee00000zzzzz','ZZZ Profile');  List&lt;User&gt; users = [SELECT Id, Name, Email, ProfileId FROM User WHERE NOT(Email like '%@example.com') AND ProfileId NOT IN :profileIds.keySet()]; System.debug(users.size()); for (User usr: users) {     System.debug(usr.id+'    '+usr.Email); }   When I run the Query in SOQL Editor, it says "unexpected token: AND"  SELECT Id, Name, Email, ProfileId FROM User WHERE NOT(Email like '%@example.com') AND  ProfileId NOT IN ('00eee000000xxxx','00eee00000yyyyy','00eee000000zzzz')   When I remove one of the clauses from the where statement, it works. I do not understand whats wrong with the query. I tried wrapping the query with in parenthesis too, but no luck. for example   List&lt;User&gt; users = [SELECT Id, Name, Email, ProfileId FROM User WHERE (NOT(Email like '%@example.com') AND ProfileId NOT IN :profileIds.keySet())];  List&lt;User&gt; users = [SELECT Id, Name, Email, ProfileId FROM User WHERE (NOT(Email like '%@example.com') AND (ProfileId NOT IN :profileIds.keySet()))];
1723
Can anyone confirm this: in a SOQL Where clause, when comparing an ID field to a 15-character string variable, the comparison works.  I didn't expect it to work, but it does and I am surprised.  I can't find any documentation to confirm it.  I thought 18-character ID was always in effect, and comparing 18-char ID to 15-char string would fail.  Example (Country__c is a lookup field):  String tmpID = 'a1he0000000EkAi'; Account acct = [select ID from Account where Country__c = :tmpID];
78550
I have a format looking like this: 983243 woiewewrsadhjf 234 093111 srewdslkjfdgdsdsf 111  Can i use sed to search for all instances of text in the third field and change only those while leaving other third fields as is? So searching for 111 in the third field, changing all third fields containing 111 into othertext, wile leaving other third fields (such as 234) as they are. If possible can you guys break down the solution so I can get educated on how the command is formed. I am here to learn.
27703
Is it possible to use an IF clause within a WHERE clause in MS SQL?  Example:  WHERE     IF IsNumeric(@OrderNumber) = 1         OrderNumber = @OrderNumber     ELSE         OrderNumber LIKE '%' + @OrderNumber + '%'
58526
As mentioned in , it's possible to use bind variables in dynamic SOQL queries.  This seems like a great way to avoid SOQL-injection, and to build a query string once but use it multiple times with different values in the variables.  I'm working on a method that returns a list of objects.  It accepts a class with multiple properties as its only parameter.  The properties of this class are used to filter the results to just the required records.  It will eventually be driven by a Visualforce component, which will be configured by querystring parameters in the URL.  I just ran into an issue where the query fails when I use dotted bind variables.  If I copy the constructed dynamic SOQL into a static query, it works fine.  This may be a bug, because in doing tests I found that :foo.bar would actually try to use local variable bar.  Here's one of my queries, which uses related custom objects.  I've stripped it down to just the part that's failing (wrapped for legibility):  result = Database.query('SELECT Name, Another_Object__r.Name,      Another_Object__r.Custom_Field__c      FROM Custom_Object__c       WHERE Another_Object__r.Custom_Field__c = :filter.deviceType');   The error reported is System.QueryException: Variable does not exist: filter.deviceType.  As mentioned above, the query works fine as static SOQL, just not dynamic:  result = [SELECT Name, Another_Object__r.Name, Another_Object__r.Custom_Field__c FROM Custom_Object__c WHERE Another_Object__r.Custom_Field__c = :filter.deviceType];   It also works in this case:  String deviceType = filter.deviceType; Database.query('SELECT Name, Another_Object__r.Name, Another_Object__r.Custom_Field__c FROM Custom_Object__c WHERE Another_Object__r.Custom_Field__c = :deviceType');   I haven't read about this being a known limitation.  I don't know if I should be using some other syntax/notation in the query -- the dotted notation appears correct.  Time to report a bug?  Thoughts on workarounds other than creating local variables to stand in for each member of the class?
18905
I've got a text file full of records where each field in each record is a fixed width.  My first approach would be to parse each record simply using string.Substring().  Is there a better way?   For example, the format could be described as:  &lt;Field1(8)&gt;&lt;Field2(16)&gt;&lt;Field3(12)&gt;   And an example file with two records could look like:  SomeData0000000000123456SomeMoreData Data2   0000000000555555MoreData       I just want to make sure I'm not overlooking a more elegant way than Substring().    Update:  I ultimately went with a regex like Killersponge suggested:  private readonly Regex reLot = new Regex(REGEX_LOT, RegexOptions.Compiled); const string REGEX_LOT = "^(?&lt;Field1&gt;.{6})" +                         "(?&lt;Field2&gt;.{16})" +                         "(?&lt;Field3&gt;.{12})";   I then use the following to access the fields:  Match match = reLot.Match(record); string field1 = match.Groups["Field1"].Value;
97214
I'm trying to do a basic "OR" on three fields using a hibernate criteria query.  Example  class Whatever{  string name;  string address;  string phoneNumber; }   I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber".
19056
Is there a way to search questions that are tagged with either tag1 or tag2?  Actually, I would like the general filter,      ([tag1] AND [tag2], ...) OR ([tag3]   AND [tag4], ...) OR ...   And even     [tag1] AND ([tag2] OR [tag3])   I need that because I'm looking for interesting questions and I have to search for each tag separately.
29504
What is the best way to replace all '&amp;lt' with &amp;lt; in a given database column? Basically perform s/&amp;lt[^;]/&amp;lt;/gi  Notes:   must work in  2000 Must be repeatable (and not end up with &amp;lt;;;;;;;;;;)
113863
Working in Marketing cloud where we are building a query that splits apart data from a single column into 4 separate columns where the delimiter is a semicolon.   Error is displayed when doing a "check syntax"   Error message: ';' is a reserved word and may not appear in your query.   We cant change the data to use a different delimiter so wanted to know if anyone knows of a work around?   select  c.contactid as subscriber_key  , coalesce(i.Preferred_Correspondence_Name, i.[first name]) as Preferred_Correspondence_Name  , i.[email address] as email  , c.casenumber  , c.Id as case_salesforce_id  ,party.name as party  , c.LastModifiedDate as last_modified_date  , c.CreatedDate as created_date  , c.Bank_Account_Change__c as bank_account_change  ,'add' as action  ,LTrim(PARSENAME(REPLACE([c.Bank_Account_Change__c],';','.'),4)) as Party_Details  ,LTrim(PARSENAME(REPLACE([c.Bank_Account_Change__c],';','.'),3)) as Party_ID_Details  ,LTrim(PARSENAME(REPLACE([c.Bank_Account_Change__c],';','.'),2)) as Bank_Account_Details  ,LTrim(PARSENAME(REPLACE([c.Bank_Account_Change__c],';','.'),1)) as Start_Date_Details  from  ENT.Case_salesforce_2 as c  inner join ENT.RecordType_Salesforce as rt on c.RecordTypeId = rt.Id  inner join ENT.account_salesforce as party on party.id = c.accountid  inner join contact i on i.[subscriber key]= c.contactid  where  Type = 'Payments'  and Sub_Type__c = 'Bank Account Change'  and Raised_By__c = 'External'  and Origin = 'Web'  and rt.Name = 'Financial Enquiries'  and c.Bank_Account_Change__c is not null
13332
I am trying to use a  as input and then creating a query with it - so I need a .    I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the Java API is still fairly new to me.
17701
I wounder how I could use an alias in a where statement.  Example :  SELECT SUBSTRING(Column1, 1, 4) + SUBSTRING(Column1, 4, 3)  AS Col1 FROM MyTable WHERE Col1 = 'MySearch'   I use MSSQL 2005
122159
Is there a way to have a statement across multiple lines without the underscore character?  It is really annoying in multi-line strings such as SQL statements, and especially  queries.  Beside from the ugliness and difficulty when changing a line (nothing lines up anymore), you can't use comments in the middle of the multi-line statement.  Examples of my daily personal hell.  dim results = from a in articles _               where a.articleID = 4 _ ' articleID     - Nope, can't do this               select a.articleName   dim createArticle as string = _     "Create table article " &amp; _     "    (articleID int " &amp; _     "    ,articleName varchar(50) " &amp; _     "    )"
91653
I want to run a find and replace on multiple values within a range in excel with values from 2 columns: A with the original word; B with the translation. I already found the VBA code to get this working for 50%, but this code runs it on the whole worskheet.  Ideally I would like to be able to run it on just the range I selected. An added bonus would be if I could also select the lookup range.  This is what I'm using this far. Thanks for your help!  Sub abbrev()             Dim abvtab() As Variant             Dim ltsheet As Worksheet             Dim datasheet As Worksheet             Dim lt As Range              'Change Lookup to the sheet name with your lookup table.             Set ltsheet = Sheets("Lookup")              'Change Data to the sheet name with your data.             Set datasheet = Sheets("Data")              'Change A2 to the top left cell (not the header) in your lookup table.             'Change B2 to top right cell.             Set lt = ltsheet.Range("A1", ltsheet.Range("B1").End(xlDown))              abvtab = lt              For i = 1 To UBound(abvtab)                 datasheet.Cells.Replace What:=abvtab(i, 1), Replacement:=abvtab(i, 2), LookAt:=xlPart, _                     SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _                     ReplaceFormat:=False             Next i End Sub
60682
I have the following QUERY  =query(XX!A2:A;" select A where A&gt;'50' ")   and  =query(YY!A2:A;" select A where A&gt;'50' ")   how do I combine these two data sources so I don't have to have two separate columns they process data to?   best would be if the 1st row from XX is followed by the 1st row of YY, 2nd row followed by 2nd row... and so on If the above option is not easily possible, it is OK for one query to be followed by the second one (if I expect correctly that the start of the second will be moved with newly added data into the first one)
85919
While cloning record i am getting the below error in the 1st line of the code, the SOQL. Can anyone help me with that.  XX_Segment__c desc1 = [select  Id, XXX_New_Keyword_Description__r.Description__c from XX_Segment__c where Availability_Forecast_XXX__c =:id1]; String s= desc1.XXX_New_Keyword_Description__r.Description__c; s= s.substring(0,3); String s1 = s+'%';   Regards