创建存储过程的问题 [英] problem in creating stored procedure
本文介绍了创建存储过程的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我是MYSQL数据库的新手....我想在MYSQL中创建存储过程..我在MSSQL中编写了相同的程序并且它正在运行但是当我在PHPMYADMIN(MYSQL)中运行它时它给出了错误:
Hello i am newbie to MYSQL Database .... i want to create stored procedure in MYSQL .. I have written the same procedure in MSSQL and it was running but when i am running it in PHPMYADMIN(MYSQL) its is giving error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@'companyna' nvarchar(150)<br />
begin<br />
select Company_Name from companynames<br />
where ' at line 2
这是我的MS SQL存储过程
this is my MS SQL Stored Procedure
create proc spgetcompanynames
@companyna nvarchar(150)
as
begin
select Company_Name from companynames
where Company_Name Like @companyna + '%'
end
这是我的MYSQL存储过程
this is my MYSQL Stored Procedure
create procedure spGetCompanyNames
@CompanyNams varchar(250)
begin
select Company_Name from companynames
where Company_Name Like @CompanyNams + '%'
end
Plz帮助我找到错误。
Plz Help me in finding the error .
推荐答案
试试这个....
try this....
Create procedure spGetComapnyNames(IN companyname varchar(150))
BEGIN
select Company_Name from companynames
where Company_Name Like companyname + '%'
END
关闭!
尝试:
Close!
Try:
create procedure spGetCompanyNames
(@CompanyNams varchar(250))
begin
select Company_Name from companynames
where Company_Name Like @CompanyNams + '%'
end
create proc spgetcompanynames
@companyna nvarchar(150)
as
begin
从公司名称中选择Company_Name
其中Company_Name喜欢@companyna +'%'
结束
在上面的查询请更改表name to Column Name(Company_Name是Where子句中的表名)。
在where子句中写入要在其中执行搜索的列名。
create proc spgetcompanynames
@companyna nvarchar(150)
as
begin
select Company_Name from companynames
where Company_Name Like @companyna + '%'
end
In above query please change table name to Column Name(Company_Name is table name in Where clause).
Write column name in which you want to perform search in where clause.
create proc spgetcompanynames
@companyna nvarchar(150)
as
begin
select Company_Name from companynames
where COLUMNAME Like @companyna + '%'
end
这篇关于创建存储过程的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文