我必須在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