Ashish Karalkar wrote:
Hello List,

I am having list of tables , what I want to do is to
filter this list of table for a particular value of
its column, the column which i will be searching is
common accross all tables in list

any clues??


Something like

SELECT * FROM
    (
    SELECT col1,col2 FROM table1
    UNION
    SELECT col1,col2 FROM table2
    UNION
    SELECT col1,col2 FROM table3
    ) AS at

WHERE at.col1=3

if the cols are different names you would change
SELECT col1,col2
to SELECT col3 as col1,col2



If you are looking for the table that has the value you will want something like -

SELECT c.relname,* FROM (
    SELECT tableoid,col1,col2 FROM table1
    UNION
    SELECT tableoid,col1,col2 FROM table2
    UNION
    SELECT tableoid,col1,col2 FROM table3
    ) as at

left join pg_class c on at.tableoid=c.oid

WHERE at.col1=3



--

Shane Ambler
[EMAIL PROTECTED]

Get Sheeky @ http://Sheeky.Biz

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

Reply via email to