title: What are the benefits of creating Stored Procedures in SQL and MySQL?
body: <p>I have a theoretical question. </p>
  
  <p>I can't see any difference between declaring a <em>function</em> within a PHP file and creating a <em>stored procedure</em> in a database that does the same thing. </p>
  
  <p>Why would I want to create a <em>stored procedure</em> to, for example, return a list of all the Cities for a specific Country, when I can do that with a PHP <em>function</em> to query the database and it will have the same result? </p>
  
  <p>What are the benefits of using <em>stored procedures</em> in this case? Or which is better? To use functions in PHP or <em>stored procedures</em> within the database? And what are the differences between the two? </p>
  
  <p>Thank you. </p>