title: Erlang mysql example
body: <p>Just wondering if anyone could give a working example of using the erlang-mysql module (<a href="http://code.google.com/p/erlang-mysql-driver/" rel="nofollow noreferrer">http://code.google.com/p/erlang-mysql-driver/</a>).</p>
  
  <p>I am new to erlang and I am trying to replace some old scripts with a few erlang batch processes.  I am able to connect to the DB and even complete a query, but I am not sure how I use the results.  Here is what I currently have:</p>
  
  <pre><code>-include("../include/mysql.hrl").
  ...
  mysql:start_link(p1, "IP-ADDRESS", "erlang", "PASSWORD", "DATABASE"),
  Result1 = mysql:fetch(p1, &lt;&lt;"SELECT * FROM users"&gt;&gt;),
  io:format("Result1: ~p~n", [Result1]),
  ...
  </code></pre>
  
  <p>I also have a prepared statement that I am also using to get just one row (if it exists) and it would be helpful to know how to access the results on that as well</p>