1 Reply Latest reply on Jul 7, 2014 4:20 PM by Carl Von Stetten

    How Can I Extract a Substring in WHERE Clause of <CFQUERY> ?

    rjd49

      Is it possible to extract a substring in the WHERE clause of either <CFQUERY> or in a Query of Queries?  I am trying to use the following query to find all email addresses with the domain "comcast.net" (i.e. everything after the "@" in the email address).  I am querying an MS-Access database table.

       

      <cfquery name="test" datasource="membership">
            SELECT email_address
            FROM tblMembers
            WHERE MID(email_address, INSTR(email_address, '@') + 1) = 'comcast.net'
      </cfquery>


      If I attempt this as a query, I get the error message "[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression."


      If I attempt it as a QoQ, I get the error message 'Encountered "MID ( email1 ,. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition,'.

       

      I would be very grateful for any help on finding something that works!  Thanks for your help!