我有两张表,一张继承了另一张:
CREATE TABLE parent (
col1 INTEGER
);
CREATE TABLE child (
col2 INTEGER
) INHERITS( parent );
// Insert some data
INSERT INTO parent( col1 ) VALUES( 1 );
INSERT INTO child( col1, col2 ) VALUES( 2, 2 );
Run Code Online (Sandbox Code Playgroud)
有什么方法可以查询父表,使其获取子表的所有列?
此查询仅返回父列:
SELECT * FROM parent;
| col1 |
| ---- |
| 1 |
| 2 |
Run Code Online (Sandbox Code Playgroud)
我想要的查询将返回父和子中的所有列:
SELECT ... -- some query, with desired result:
| col1 | col2 |
| ---- | ---- |
| 1 | …Run Code Online (Sandbox Code Playgroud)