Re: searching a value in a variable/field in all tables in a schema

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ruiqiang Chen <chenrq2005(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: searching a value in a variable/field in all tables in a schema
Date: 2018-08-30 20:51:29
Message-ID: CAKFQuwaONZObovF2COnS_d1yH_pD4rhwOmyHL+O=fPJFHGwxZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 30, 2018 at 1:44 PM, Ruiqiang Chen <chenrq2005(at)gmail(dot)com> wrote:

> Does anyone have experience of searching a value in a variable/field in
> all tables in a schema?
>

SELECT 'Tbl1'::text AS loc, fld
FROM schema.tbl1
WHERE fld = 'value'
[UNION ALL
SELECT 'Tbl2'::text AS loc, fld
FROM schema.tbl2
WHERE fld = 'value'
...]

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Cross 2018-08-30 22:24:28 Re: Ways to deal with large amount of columns;
Previous Message Ruiqiang Chen 2018-08-30 20:44:09 searching a value in a variable/field in all tables in a schema