title: mysql order string as number
body: <p>I have searched for days for a way to sort a string as number in mysql.</p>
  
  <p>My rows look like this:</p>
  
  <p>order_column</p>
  
  <pre><code>1.1.2
  1.1.100
  1.1.1
  </code></pre>
  
  <p>Ordering ascending by this column in mysql will produce:</p>
  
  <pre><code>1.1.1
  1.1.100
  1.1.2
  </code></pre>
  
  <p>I am interested in getting the following result:</p>
  
  <pre><code>1.1.1
  1.1.2
  1.1.100
  </code></pre>
  
  <p>Is there a way to produce this result using SQL?</p>
  
  <p>Other possible values of my column:</p>
  
  <pre><code>28.1999.1.1
  1
  1.1.154.20
  100.1.1.1.1.15
  </code></pre>
  
  <p>Thanks, i appreciate everybody's time.</p>
  
  <p>EDIT:
  <a href="https://stackoverflow.com/questions/846201/fast-relational-method-of-storing-tree-data-for-instance-threaded-comments-on-a">Fast Relational method of storing tree data (for instance threaded comments on articles)</a>
  Take a look at the first answer, the one by Ayman Hourieh. I am trying to get that solution working. My website has no more than 10k comments per article, so i found a work-around like this:</p>
  
  <pre><code>000001
  000002
  000002.000001
  000002.000001.000001
  000002.000002
  000002.000003
  000003
  </code></pre>
  
  <p>Basically, putting zeros before my comment counter so that string comparison doesn't fail. But this will only work for 99999 comments. I can add more zeros, lets say 10 zeros, and that will work for 999999999 comments, but i was hoping for a more elegant solution.</p>