title: Use SET @variable=? inside of mysqli prepared statement
body: <p>i have a query that uses a few variables in mysql. The query looks something like this:</p>
  
  <pre><code>SET @var1 = 1;
  SET @var2 = 2;
  SELECT * FROM table WHERE table.column1=@var1 
  AND table.column2=@var2
  AND table.colum3=@var1 * @var2;
  </code></pre>
  
  <p>I would like to make a prepared statement like:</p>
  
  <pre><code>$sql=' SET @var1 = ?;
  SET @var2 = ?;
  SELECT * FROM table WHERE table.column1=@var1 
  AND table.column2=@var2
  AND table.colum3=@var1 * @var2;'
  </code></pre>
  
  <p>and then just bind two params to it. But this gives me an mysql sytax error near the SET @var1=?;</p>
  
  <p>Of course, in the example, I could bind three variables and do the calculations before querying. In my real query there are more advanced calculations and I would need to bind the same variable to multiple places. And that seems like repeating and bad coding practice.</p>
  
  <p>Any solutions for this? </p>