使用 Top 存储唯一值是不可能的 Sybase
storing a unique value with Top is not posible Sybase
我想知道为什么我不能在 sybase 15.5 中这样做
我的 table 是呼叫 "web_titles"
title_id 是一个 varchar(6)
declare @idAux varchar(6)
set @idAux = (select top 1 title_id from web_titles)
如果我这样做
select top 1 title_id from web_titles
return
title_id
-----------
PC8888
但如果我尝试设置变量,我会收到
Sybase 错误
"Incorrect syntax near the keyword 'top' "
我不明白为什么。有什么想法吗?
要为变量赋值,您可以使用:
declare @idAux varchar(6);
select top 1 @idAux = title_id from web_titles;
请记住,没有 ORDER BY
的 TOP 1
是不可靠的。
在 ASE 的子查询中不允许使用 TOP、ORDER BY 和 UNION
我想知道为什么我不能在 sybase 15.5 中这样做 我的 table 是呼叫 "web_titles"
title_id 是一个 varchar(6)
declare @idAux varchar(6)
set @idAux = (select top 1 title_id from web_titles)
如果我这样做
select top 1 title_id from web_titles
return
title_id
-----------
PC8888
但如果我尝试设置变量,我会收到
Sybase 错误
"Incorrect syntax near the keyword 'top' "
我不明白为什么。有什么想法吗?
要为变量赋值,您可以使用:
declare @idAux varchar(6);
select top 1 @idAux = title_id from web_titles;
请记住,没有 ORDER BY
的 TOP 1
是不可靠的。
在 ASE 的子查询中不允许使用 TOP、ORDER BY 和 UNION