如何编写查询以查找所有客户名称及其寻址是否有地址?

时间:2017-05-16 07:58:10

标签: sql

如何编写查询以查找所有客户名称及其地址是否有地址?

CREATE TABLE test.address
(
  id integer NOT NULL,
  street text,
  city text,
  CONSTRAINT address_pkey PRIMARY KEY (id)
)


CREATE TABLE test.customer
(
  id integer NOT NULL,
  name text,
  CONSTRAINT customer_pkey PRIMARY KEY (id)
)


CREATE TABLE test.customer_addresses
(
  id integer,
  customer_id integer,
  address_id integer,
  CONSTRAINT customer_addresses_address_id_fkey FOREIGN KEY (address_id)
    REFERENCES test.address (id),
  CONSTRAINT customer_addresses_customer_id_fkey FORE IGN KEY (customer_id)
    REFERENCES test.customer (id)
)

0 个答案:

没有答案