pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: tiplip <chengwei02@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Multiple tables query on Mapserver
Date: Thu, 2 Feb 2012 00:22:46 -0500
Message-ID: <59D2E8F6-962D-4DDC-96C0-5985AE0F4D9A@yahoo.com> (raw)
In-Reply-To: <1328159813393-5449642.post@n5.nabble.com>
References: <1328159813393-5449642.post@n5.nabble.com>

On Feb 2, 2012, at 0:16, tiplip <chengwei02@gmail.com> wrote:

> Hi all,
> 
> I have a couple of tables with same structure but standing for different
> layers(1,2,3...) respectivle for Mapserver,
> 
> table1
>        gid    |  id    | name      | address        | post code  | layer   
> |  geom
> -----------+------+----------+-------------+-----------+--------+------------
>        1          1       'name11'      'address11'          102356       1      
> geom11
>        2          2       'name12'      'address12'          102356       1      
> geom12
>        -          -        'name1-'      'address1-'          102356      
> 1       geom1-
> 
> table2
>        gid    |  id    | name      | address        | post code  | layer   
> |  geom
> -----------+------+----------+-------------+-----------+--------+------------
>        1          1       'name21'     'address21'          102356       2      
> geom21
>        2          2       'name22'     'address22'          102356       2      
> geom22
>        -          -        'name2-'     'address2-'          102356       2      
> geom2-
> 
> 
> table3
>        gid    |  id    | name      | address        | post code  | layer   
> |  geom
> -----------+------+----------+-------------+-----------+--------+------------
>        1          1       'name31'      'address31'          102356       3      
> geom31
>        2          2       'name32'      'address32'          102356       3      
> geom32
>        -          -        'name3-'      'address3-'          102356      
> 3       geom3-
> 
> 
> I want to get query results from table1, 2, 3... if key word matches, say
> name like 'name' as follows:
> 
> input 'name', results will be like
> 
> table2
>        gid    |  id    | name      | address        | post code  | layer    
> |  geom
> -----------+------+----------+-------------+-----------+---------+------------
>        1          1       'name11'      'address11'          102356       1      
> geom11
>        2          2       'name12'      'address12'          102356       1      
> geom12
>        3          3       'name21'     'address21'          102356       2      
> geom21
>        4          4       'name22'     'address22'          102356       2      
> geom22
>        5          5       'name31'      'address31'          102356       3      
> geom31
>        6          6       'name32'      'address32'          102356       3      
> geom32
>        -          -       ---------      ---------           -------      -          
> -
> 
> 
> can I achieve that results with a single query sentence? and how?
> any good ideas will be appricated?
> 
> thanks
> 
> 

The general method is to use "UNION" but not sure about the changing of the gid and id values...

David J.


view thread (5+ messages)  latest in thread

Message-ID: <59D2E8F6-962D-4DDC-96C0-5985AE0F4D9A@yahoo.com>
Permalink:  ../59D2E8F6-962D-4DDC-96C0-5985AE0F4D9A@yahoo.com/
Also on:    postgresql.org/message-id/59D2E8F6-962D-4DDC-96C0-5985AE0F4D9A@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: polobo@yahoo.com, chengwei02@gmail.com
  Subject: Re: Multiple tables query on Mapserver
  In-Reply-To: <59D2E8F6-962D-4DDC-96C0-5985AE0F4D9A@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox