Re: Extract from text id other table - PG 9.1

From: Jan de Visser <jan(at)de-visser(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Patrick B <patrickbakerbr(at)gmail(dot)com>
Subject: Re: Extract from text id other table - PG 9.1
Date: 2017-06-07 12:24:49
Message-ID: 9185769.JMuuZeW7Ha@coyote
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday, June 6, 2017 10:32:16 PM EDT Patrick B wrote:
> Hi guys,
>
> I've got tableA with 3 columns.
>
> id(seriaL) | type(character varying(256)) | string(character varying(256))
>
> I have the type/string value stored in another table, and from that i would
> like to get the id.
>
> Example:
> http://dbfiddle.uk/?rdbms=postgres_9.6&fiddle=15c571caa36876f00a0a2eaace703a
> 2b
>
> How can I extract, from that tablea.type_m column the tableb.id value?

SELECT b.id FROM tableb b, tablea a
WHERE (b.type || '/' || b.string = a.type_m) AND (a.id = 2);

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ADSJ (Adam Sjøgren) 2017-06-07 13:33:26 ERROR: unexpected chunk number 0 (expected 1) for toast value 76753264 in pg_toast_10920100
Previous Message Kouber Saparev 2017-06-07 09:44:27 Re: Writing a C function to return the log file name