我不确定mysql语句有什么问题。错误消息为:“ IN在此位置无效,期望:EOF,';'
这是我的sql语句:
CREATE VIEW collab AS
SELECT a.author_name AS Author, ca.no0fCollab
FROM (SELECT * FROM author) as a, (SELECT * FROM coauthors) as ca
WHERE a.author_id = ca.author_id
AND a.author_id IN (
SELECT UA.author_id
FROM uniq_authored UA JOING publication p
ON P.pubid = UA.pubid
WHERE (p.pubkey LIKE 'journals/%' OR p.pubkey LIKE 'conf/%')
AND p.title LIKE '%data%'
);
答案 0 :(得分:0)
您不能在视图中使用FROM(子查询)
但您并不需要...。您可以使用join并避免子查询来重构查询
CREATE VIEW collab AS
select a.author_name Author, ca.no0fCollab
FROM author a
INNER JOIN coauthors ca ON a.author_id = ca.author_id
INNER JOIN uniq_authored ua ON a.author_id = ua.author_id
INNER JOIN publication p ON P.pubid = ua.pubid
AND (p.pubkey LIKE 'journals/%' OR p.pubkey LIKE 'conf/%')
AND p.title LIKE '%data%'