Skip site navigation (1) Skip section navigation (2)

Re: Create a row-wise conditional view

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pedro Tarrafeta <ptarra(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Create a row-wise conditional view
Date: 2005-07-24 17:45:51
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Pedro Tarrafeta <ptarra(at)gmail(dot)com> writes:
> I'm trying to create a set of views like this. Let's say I have 2 tables 
> with the same structure. One of them is the "master" table (left side) and
> the other one has a different "version" of the fields only for certain rows.

> I want to create a view that would have the same structure as the tables,
> holding all the records from the master table but when there's a record 
> matching on the secundary then use those. 

Maybe something like

	SELECT * FROM table1
	SELECT * FROM table2
	  WHERE NOT EXISTS(SELECT 1 FROM table1 where id =;

(This may have table1 and table2 reversed from what you were thinking.)

This is going to be pretty messy and inefficient, though, so I'd really
counsel rethinking your data design.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Michael AvilaDate: 2005-07-25 00:58:35
Subject: Re: Utility to Convert MySQL to PostgreSQL
Previous:From: Sean DavisDate: 2005-07-24 17:26:11
Subject: Re: Utility to Convert MySQL to PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group