Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL where clause in store procedure 2

Status
Not open for further replies.

robert201

Programmer
Jul 18, 2007
80
TH
Hello,

I have the following stored procedure:

But I get the following error message on the where clause. The staffID is an input.
Error Code : 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 'WHERE StaffID = _StaffID;

Many thanks for any assistance.

Steve

Code:
CREATE PROCEDURE `erestaurant`.`GetOrdersSelByStaffID`(IN _StaffID INTEGER) 
    /*LANGUAGE SQL
    | [NOT] DETERMINISTIC
    | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
    | SQL SECURITY { DEFINER | INVOKER }
    | COMMENT 'string'*/
    BEGIN
	
	SELECT * FROM Orders;
	WHERE StaffID = _StaffID;
    END$$

DELIMITER ;
 
Should there be a semi colon after Orders ?

I'm only guessing because I don't know how to write Stored Procedures.


Andrew
Hampshire, UK
 
the SQL inside stored procedures is the same SQL as in ordinary queries

the semicolon terminates the SELECT

the WHERE (incorrectly) starts a new statement

:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top