編集ポスト上の制約に基づいて、異なるテーブルからのデータの表示:PostgreSQLの - テーブルの1
だから私は、以下の次のテーブルを持って、私はUniMember、テーブルからの電話からフィールド名を表示しようとしていますAflの終了フィールドがnullであるという制約に基づいて、テーブルAflのスタッフと開始フィールド。私は非常に新しいPostgresqlであり、基本的には2日間これに固執しています。私は多くの異なるクエリを試みましたが、表示することができませんでした。
期待される出力は、次の行に沿っている必要があります。
名前|電話|開始
ありがとう!
create table UniMember (
id integer, -- PG: serial
unswid integer unique, -- staff/student id (can be null)
password ShortString not null,
family LongName,
given LongName not null,
title ShortName, -- e.g. "Prof", "A/Prof", "Dr", ...
sortname LongName not null,
name LongName not null,
primary key (id)
);
create table Staff (
id integer references People(id),
office integer references Rooms(id),
phone PhoneNumber, -- full number, not just extension
primary key (id)
);
create table Afl (
staff integer references Staff(id),
orgUnit integer references OrgUnits(id),
role integer references Staff_roles(id),
isPrimary boolean, -- is this role the basis for their employment?
starting date not null, -- when they commenced this role
ending date, -- when they finshed; null means current
primary key (staff,orgUnit,role,starting)
);
試した試行されたクエリと共にテーブル構造を投稿する必要があります。 –
* **あなたの質問に** [EDIT] **し、そのデータに基づいていくつかのサンプルデータと予想される出力を追加してください。 [**フォーマットされたテキスト**](http://stackoverflow.com/help/formatting)、[スクリーンショットなし](http://meta.stackoverflow.com/questions/285551/why-may-i-not -upload-images-of-code-on-so-ask-a-question/285557#285557) –