title: How to select one row randomly taking into account a weight?
body: <p>I have a table which looks like that:</p>
  
  <pre><code>id: primary key
  content: varchar
  weight: int
  </code></pre>
  
  <p>What I want to do is randomly select one row from this table, but taking into account the weight. For example, if I have 3 rows:</p>
  
  <pre><code>id, content, weight
  1, "some content", 60
  2, "other content", 40
  3, "something", 100
  </code></pre>
  
  <p>The first row has 30% chance of being selected, the second row has 20% chance of being selected, and the third row has 50% chance of being selected.</p>
  
  <p>Is there a way to do that? If I have to execute 2 or 3 queries it's not a problem.</p>