Sql查询中只能指定一个表达式
Sql查询中只能指定一个表达式Sql查询中只能指定一个表达式,sql,sql-server,sql-server-2012,Sql,Sql Server,Sql Server 2012,Sql查询中只能指定一个表达式 select PageID from page where PageID in (select DocumentId from PDFDocument where DocumentId in (select * from RunDocument) ) 您有选择*,其中只需要一列。您只需提及以下列即可解决此问题: select
select PageID
from page
where PageID in (select DocumentId
from PDFDocument
where DocumentId in (select * from RunDocument)
)
您有
选择*
,其中只需要一列。您只需提及以下列即可解决此问题:
select PageID
from page
where PageID in (select DocumentId
from PDFDocument
where DocumentId in (select DocumentId from RunDocument)
---------------------------------------------^
);
您有
选择*
,其中只需要一列。您只需提及以下列即可解决此问题:
select PageID
from page
where PageID in (select DocumentId
from PDFDocument
where DocumentId in (select DocumentId from RunDocument)
---------------------------------------------^
);
你可以这样试试
SELECT pg.PageID
FROM page pg
INNER JOIN PDFDocument pd
ON pd.DocumentId = pg.PageID
INNER JOIN RunDocument rd
ON rd.DocumentId = pd.DocumentId
使用子查询
SELECT pg.PageID
FROM page pg
WHERE EXISTS (SELECT 1
FROM PDFDocument pd
INNER JOIN RunDocument rd
ON rd.DocumentId = pd.DocumentId
AND pd.DocumentId = pg.PageID);
你可以这样试试
SELECT pg.PageID
FROM page pg
INNER JOIN PDFDocument pd
ON pd.DocumentId = pg.PageID
INNER JOIN RunDocument rd
ON rd.DocumentId = pd.DocumentId
使用子查询
SELECT pg.PageID
FROM page pg
WHERE EXISTS (SELECT 1
FROM PDFDocument pd
INNER JOIN RunDocument rd
ON rd.DocumentId = pd.DocumentId
AND pd.DocumentId = pg.PageID);
你听说过加入
吗?用JOIN
来表达你的查询要容易得多,而不是嵌套在子查询中的。我需要子查询而不是JOIN,先生,你听说过JOIN
吗?用JOIN
表达查询将比在
子查询中嵌套容易得多。我需要子查询而不是JOIN SIR,