vendredi 27 février 2015

Query parent table and get child tables columns


I have two tables, one inherits the other:



CREATE TABLE parent (
col1 INTEGER
);

CREATE TABLE child (
col2 INTEGER
) INHERITS( parent );


Is there any way to query the parent table, such that it gets all of the columns of the child tables



// Insert some data
INSERT INTO parent( col1 ) VALUES( 1 );
INSERT INTO child( col1, col2 ) VALUES( 2, 2 );

// This query returns just the parent columns
SELECT * FROM parent;

| col1 |
| ---- |
| 1 |
| 2 |

// My desired query would return all columns in parent and child
SELECT.... // Some query, with desired result:

| col1 | col2 |
| ---- | ---- |
| 1 | NULL |
| 2 | 2 |




Aucun commentaire:

Enregistrer un commentaire