Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Row_Number()函数从SQL Server转换为sqlite_Sql_Sql Server_Sqlite - Fatal编程技术网

将Row_Number()函数从SQL Server转换为sqlite

将Row_Number()函数从SQL Server转换为sqlite,sql,sql-server,sqlite,Sql,Sql Server,Sqlite,我正在将我的SQL Server数据库转换为sqlite。我有一个使用Row_Number函数的存储过程。如何在sqlite中编写SQL Server的以下查询,因为行号不能在sqlite中使用。还有别的选择吗 SELECT * FROM (SELECT tblDomains.*, ROW_NUMBER() OVER (ORDER BY tblDomains.DomainName ASC) AS rowNum FROM

我正在将我的SQL Server数据库转换为sqlite。我有一个使用Row_Number函数的存储过程。如何在sqlite中编写SQL Server的以下查询,因为行号不能在sqlite中使用。还有别的选择吗

SELECT *
FROM 
    (SELECT 
         tblDomains.*,
         ROW_NUMBER() OVER (ORDER BY tblDomains.DomainName ASC) AS rowNum
     FROM
         tblDomains
     WHERE 
         (1=1) AND (IsDeleted = 'False')
         AND (DomainName LIKE '%hostingcontroller.com%')) AS q
WHERE 
    q.rowNum > 0 AND q.rowNum < 2
SQLite支持行号,但您可以将其表述为:

SELECT d.*
FROM tblDomains d 
WHERE d.IsDeleted = 'False' AND
      d.DomainName LIKE '%hostingcontroller.com%'
ORDER BY d.DomainName ASC
LIMIT 1;

在SQL Server中,您可以将“限制1”替换为“选择顶部1”。

LIMIT在我的情况下不起作用,因为我正在根据给定的2个上下动态参数进行分页。@SharjeelMalik。1这回答了您提出的问题。2如果您正在进行分页,则应使用限制/偏移。所以答案基本上是一样的。