我必须在使用存在命令的 sql 中编写一个创建视图语句。我尝试在网上查找它,但我遇到了一些困难。我尽力编写创建视图文件,但它现在无法正常工作。我知道我需要在我的语句中使用关键字 EXIST。我试图创建的声明是
Write a query that shows returns the name and city of the university that has no people in database
that are associated with it.
到目前为止我写的代码是这样的
CREATE VIEW exist AS
SELECT a.university_name, a.city
FROM lab5.university as a
INNER JOIN lab5.person as b
ON a.uid = b.uid
WHERE b.uid NOT EXIST
我正在使用的表是
Table "table.university"
Column | Type | Modifiers
-----------------+-----------------------+--------------------------------------
uid | integer | not null default nextval('university_uid_seq'::regclass)
university_name | character varying(50) |
city | character varying(50) |
和
Table "table.person"
Column | Type | Modifiers
--------+-----------------------+-----------------------------------------------
pid | integer | not null default nextval('person_pid_seq'::reg class)
uid | integer |
fname | character varying(25) | not null
lname | character varying(25) | not null