Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XCci2-0005kK-UV for pgsql-sql@arkaria.postgresql.org; Wed, 30 Jul 2014 22:50:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XCci2-0003mm-AN for pgsql-sql@arkaria.postgresql.org; Wed, 30 Jul 2014 22:50:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XCci1-0003mg-C2 for pgsql-sql@postgresql.org; Wed, 30 Jul 2014 22:50:57 +0000 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XCchy-0006g1-1e for pgsql-sql@postgresql.org; Wed, 30 Jul 2014 22:50:55 +0000 Received: by mail-wg0-f52.google.com with SMTP id a1so1890603wgh.11 for ; Wed, 30 Jul 2014 15:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:from:subject:date:to; bh=2TbIaAweLYMFMxiQbIs7WxRBesP/RdomHnuOdosPbWY=; b=XwgCOfB5RPGX6QRxCGJLS5UGQmjF1VE8BYd3ayoo9bsImFoFgkVR1hvpj+c97GldlL /IDKK4K+1GeNykmlxMhLFw3UxbDrr4XM3xo1nxHAiB4cZ33Sg/2y+8a5bG0/jK0aHfpS U8tanD56ysT+3ufmftxkR/WemFFyezGnYzPlD746xsR5JkFJILWxW6184oLO7FvO634s 7uwl19gi8QJdQtxchErKiP5jYkA5zDHK0Kb9zR5SiPS6dg0LNe/dFH4NOlHAwfPdp9qK icBViH4OqKjGYyJN2KJ8OdKBEQ12MrV3HGecYdVu49Wm6HZJUcmoUyKrHojJZfTvLUJs /gtg== X-Received: by 10.180.21.235 with SMTP id y11mr9860975wie.75.1406760652112; Wed, 30 Jul 2014 15:50:52 -0700 (PDT) Received: from [192.168.1.11] ([46.7.149.72]) by mx.google.com with ESMTPSA id bx2sm8860896wjb.47.2014.07.30.15.50.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 15:50:50 -0700 (PDT) References: In-Reply-To: Mime-Version: 1.0 (iPhone Mail 8L1) Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary=Apple-Mail-20--1042143391 Message-Id: <1D742D88-394D-4B9D-ADF8-D0C832A5B16D@gmail.com> Cc: "pgsql-sql@postgresql.org" X-Mailer: iPhone Mail (8L1) From: Oliver d'Azevedo Christina Subject: Re: Reg: Sql Join Date: Thu, 31 Jul 2014 00:09:43 +0100 To: CrashBandi X-Pg-Spam-Score: -2.0 (--) 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 --Apple-Mail-20--1042143391 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I am not sure if I understand what you're trying to achieve.=20 It would help if you could provide an output example.=20 Best, Oliver=20 Sent via iPhone, apologies for any errors Em 30/07/2014, =C3=A0s 11:08 PM, CrashBandi escr= eveu: > Hi, >=20 > I am having the following question. I am not sure how to approach it. Plea= se help! >=20 > table A > name col1 col2 col3 col4 > apple 100 11111 1 APL > orange 200 22222 3 ORG > carrot 300 33333 3 CRT >=20 >=20 > table B > custom_name value obj_type obj_id > apple a FR 100 > orange o FR 200 > carrot c VG 300 > apple d FR 11111 > orange e VG 22222 > carrot f UC 33333 > apple h VG 1 > orange o FR 3 > carrot c VG 3 >=20 > when obj_type =3D'FR' then join on col1 > When obj_type=3D'VG' then join on col2 > When obj_type=3D'UC' then join on col2 >=20 > Thanks In advance, > CB > =20 --Apple-Mail-20--1042143391 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
I am not sure if I understand what you'= re trying to achieve. 
It would help if you could provide an o= utput example. 

Best,
Oliver 

Sent via iPhone, apologies for any errors

Em 30/0= 7/2014, =C3=A0s 11:08 PM, CrashBandi <crashbandicootu@gmail.com> escreveu:

Hi,

I am having the following question. I am not sure how to approach it= . Please help!

table A
name co= l1 co= l2 co= l3 co= l4
a= pple 100 11111 1 APL<= /td>
o= range 200 22222 3 ORG<= /td>
c= arrot 300 33333 3 CRT<= /td>


table B
custom_na= me value obj_type obj_id
apple a FR 100
orange o FR 200
carrot c VG 300
apple d FR 11111
orange e VG 22222
carrot f UC 33333
apple h VG 1
orange o FR 3
carrot c VG 3

when obj_type =3D'= FR' then join on col1
When obj_type=3D'VG' then join on col2
=
When obj_type=3D'UC' then join on col2

Thanks In advance,
CB
 
= --Apple-Mail-20--1042143391--