Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceV7Z-0005Ne-32 for pgsql-sql@arkaria.postgresql.org; Thu, 16 Feb 2017 23:05:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ceV7Y-0006Uf-HZ for pgsql-sql@arkaria.postgresql.org; Thu, 16 Feb 2017 23:05:52 +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 1ceV7Y-0006UW-2R for pgsql-sql@postgresql.org; Thu, 16 Feb 2017 23:05:52 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceV7W-0002uZ-85 for pgsql-sql@postgresql.org; Thu, 16 Feb 2017 23:05:51 +0000 Received: from mben.nabble.com (unknown [162.253.133.72]) by mwork.nabble.com (Postfix) with ESMTP id 903E12D4A616E for ; Thu, 16 Feb 2017 16:05:48 -0700 (MST) Date: Thu, 16 Feb 2017 16:05:48 -0700 (MST) From: sqlQuestions To: pgsql-sql@postgresql.org Message-ID: <1487286348488-5944801.post@n3.nabble.com> In-Reply-To: References: <1487283597419-5944796.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 Thanks for your response David. I took out the WHEN table2.category IS NULL clause because I only want it to pull the category from table2 when the lookup_value exists in description, otherwise pull the table1 category. NULL doesn't matter to me. Unfortunately, it still always pulls the category from table1. SELECT code, description, CASE WHEN description LIKE ('%' || lookup_value || '%') THEN table2.category ELSE table1.category END FROM table1 LEFT JOIN table2 USING (code); -- View this message in context: http://postgresql.nabble.com/Conditional-Lookup-Table-with-Like-tp5944796p5944801.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