Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cemlI-0000Tz-Tj for pgsql-sql@arkaria.postgresql.org; Fri, 17 Feb 2017 17:56:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cemlI-00069q-Go for pgsql-sql@arkaria.postgresql.org; Fri, 17 Feb 2017 17:56:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cemlI-00069h-5b for pgsql-sql@postgresql.org; Fri, 17 Feb 2017 17:56:04 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cemlG-00016q-F8 for pgsql-sql@postgresql.org; Fri, 17 Feb 2017 17:56:03 +0000 Received: from mben.nabble.com (unknown [162.253.133.72]) by mwork.nabble.com (Postfix) with ESMTP id ABF2F2D74F886 for ; Fri, 17 Feb 2017 10:56:01 -0700 (MST) Date: Fri, 17 Feb 2017 10:56:01 -0700 (MST) From: sqlQuestions To: pgsql-sql@postgresql.org Message-ID: <1487354161516-5944935.post@n3.nabble.com> In-Reply-To: References: <1487283597419-5944796.post@n3.nabble.com> <1487286348488-5944801.post@n3.nabble.com> <1487345617421-5944908.post@n3.nabble.com> Subject: Re: Conditional Lookup Table with Like MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org That's pretty cool, I didn't know that one. But I still want to return the result from table1 when there is null category. This returns 4 correct results but needs to return the two product_code 3s with null category: SELECT table1.product_code, table1.date_signed, table1.description, COALESCE (( SELECT table3.category FROM table3 WHERE table3.psc_code = table1.product_code AND lower(table1.description) LIKE ('%' || lower(table3.lookup_value) || '%') ), table2.category) FROM table1 JOIN table2 ON table2.psc_code = table1.product_code WHERE date_signed = '2017-02-01'; -- View this message in context: http://postgresql.nabble.com/Conditional-Lookup-Table-with-Like-tp5944796p5944935.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql