SQL to MySQL query
SQL to MySQL query
Hey im using this script for server side paging with .NET and SQL 2008 and its working great.
SELECT * INTO #temp1 FROM item where BLOCKED='0'
SELECT *
FROM
(SELECT row_number() OVER (ORDER BY item_id asc) AS RowNumber , *
FROM
(SELECT (SELECT count(#temp1.NO)
FROM
#temp1) AS TotalRows
, ( SELECT count(NO) FROM #temp1 ) AS TotalDisplayRows ,*
FROM
#temp1 ) RawResults) Results
WHERE
RowNumber BETWEEN 1 AND 10
ive tried converting it to MySQL but there is no OVER statement in MySQL and am getting confused as how to make the changes. Ive added the new table creation at the top and i have tried using a incremenet instead of over
@curRank := @curRank + 1 AS rank
instead of
row_number() OVER (ORDER BY item_id asc) AS RowNumber
but its not working
CREATE TEMPORARY TABLE IF NOT EXISTS temp1 AS (SELECT * INTO temp1 FROM item where BLOCKED='0');
SELECT *
FROM
(SELECT row_number() OVER (ORDER BY item_id asc) AS RowNumber , *
FROM
(SELECT (SELECT count(temp1.NO)
FROM
temp1) AS TotalRows
, ( SELECT count(NO) FROM temp1 ) AS TotalDisplayRows ,*
FROM
temp1 ) RawResults) Results
WHERE
RowNumber BETWEEN 1 AND 10
Im not great at MySQL so any help would be great...thanks