Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3LB8-00059Z-1P for pgsql-general@arkaria.postgresql.org; Thu, 29 Aug 2019 14:13:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i3LB6-00007i-QC for pgsql-general@arkaria.postgresql.org; Thu, 29 Aug 2019 14:13:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3LB6-0008L5-Ae for pgsql-general@lists.postgresql.org; Thu, 29 Aug 2019 14:13:32 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i3LB3-00051N-Ou for pgsql-general@lists.postgresql.org; Thu, 29 Aug 2019 14:13:31 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 9D5F99939A for ; Thu, 29 Aug 2019 07:13:27 -0700 (PDT) Date: Thu, 29 Aug 2019 07:13:27 -0700 (PDT) From: Rich Shepard Reply-To: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Selecting rows having substring in a column Message-ID: User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Using postgres-11.1 here. My SQL knowledge needs expanding and my web searches have not found a satisfactory answer. I hope to learn the correct approach here. A table (Fishes) has an attribute column stream_trib with values such as Small Creek trib to Winding River Roaring River trib to Winding River and I want to find all rows containing Winding River in that column. The postgres substring function takes as arguments the substring, starting position, and length. In my table the staring position varies although the length remains constant. I need to learn how to construct a SELECT statement that returns the set of rows containing the substring 'Winding River'. A pointer to references would be great; so would a detailed lesson in handling this and similar queries. Regards, Rich