0

我知道这是一个简单的问题,但我无法让它发挥作用。

这是我在我的查询SqlCommand

SELECT * FROM zipcode  WHERE city LIKE @prefixtext + '%' ;

我只想要 10 个结果,其他所有答案都表明

SELECT TOP 10 * FROM zipcode  WHERE city LIKE @prefixtext + '%' ;
SELECT * FROM zipcode  WHERE city LIKE @prefixtext + '%'  LIMIT 10 ;

两者都不起作用

4

3 回答 3

2

我相信这些都是正确的。

甲骨文:

select * from zipcode where city like @prefixtext + '%' and rownum <=10

SQL Server/Sybase:

select top 10 * from zipcode where city like @prefixtext + '%'

DB2/PostgreSQL:

select * from zipcode where city like @prefixtext || '%' fetch first 10 rows only

MySQL:

select * from zipcode where city like @prefixtext + '%' limit 10
于 2012-06-07T04:49:31.877 回答
0
declare @like varchar(50)

set @like = @prefixtext + '%';

SELECT TOP 10 * FROM zipcode  WHERE city LIKE @like
于 2012-06-07T04:41:13.903 回答
-1
Select * from zipcode where city like @prefixtext + '%'
于 2012-09-11T09:57:21.093 回答