选择“SQL 命令”

本文关键字:命令 SQL 选择 | 更新日期: 2023-09-27 18:36:35

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

这是我在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 ;

两者都不起作用

选择“SQL 命令”

我相信

这些都是正确的。

神谕:

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
declare @like varchar(50)
set @like = @prefixtext + '%';
SELECT TOP 10 * FROM zipcode  WHERE city LIKE @like
Select * from zipcode where city like @prefixtext + '%'