我必须在sql中使用一个exist命令编写一个创建视图语句。我试着在网上查找,但我有一些困难。我尽我所能写了创建视图文件,但它现在还没有工作。我知道我需要在我的声明中使用关键字EXIST。我想创建的语句是使用EXIST命令创建一个sql视图语句
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