[英]Translate from MSSQL to MySQL
Can anyone translate me this MSSQL expression to MySQL? 任何人都可以将此MSSQL表达式翻译成MySQL吗?
CREATE PROCEDURE `spGetEmployees`
@StartIndex int,
@MaximumRows int
as
BEGIN
select EmployeeID,
Name,
Gender,
City,
StartDate
from (select row_number()
over (order by EmployeeID)
as RowNumber,
EmployeeID,
Name,
Gender,
City,
StartDate
from tblEmployee) Employees
where RowNumber >= @StartIndex
and RowNumber < (@StartIndex + @MaximumRows);
END
tblEmployee
is a real table and Employees is derived table. tblEmployee
是真实表,而Employees是派生表。
The general syntax for mysql procedures is mysql过程的一般语法是
CREATE PROCEDURE storedProcedureName( IN someString VarChar(150) )
BEGIN
-- Sql queries goes here
END
IN your case, your procedure would be something like: 在您的情况下,您的过程将类似于:
CREATE PROCEDURE spGetEmployees( IN StartIndex int, IN MaximumRows int)
BEGIN
select EmployeeID, Name, Gender, City, StartDate from
(select row_number() over (order by EmployeeID) as RowNumber, EmployeeID, Name,
Gender, City, StartDate
from tblEmployee) Employees
-- this part you may want to use limit or other mysql functions
--where RowNumber >= StartIndex and RowNumber < (StartIndex + MaximumRows);
END
If you also need, the basic syntax of temporary tables in MySQL is something like: 如果您还需要,MySQL中临时表的基本语法如下所示:
CREATE TEMPORARY TABLE tableName(
emp_id VARCHAR(10),
emp_Name VARCHAR(50),
emp_Code VARCHAR(30),
emp_Department VARCHAR(30)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.