Skip to content
Advertisement

Creat procedure in mysql

I was learning sql from w3schools.Here is given simple mysql procedure but somehow I couldn’t to write down this procedure I’m new in sql please could you provide me with feedback. enter image description here

  DELIMITER //
CREATE PROCEDURE getAllAgents
BEGIN
SELECT
 * FROM agents
 END //
 DELIMITER ; 

When I try to execute this procedure I’m keep going to get following error

Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘begin select * from agents end’ at line 2

Advertisement

Answer

Try bellow

DELIMITER //
CREATE PROCEDURE SelectAllCustomers

BEGIN
  SELECT * FROM Customers

END //
DELIMITER ;



  call SelectAllCustomers

if you use mariyaDB

CREATE procedure selectAllCustomers()
SELECT * FROM customer

to execute

call selectAllCustomers
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement