title: MySQL: Help with script needed
body: <pre><code>CREATE TABLE `photos` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `photo` varchar(255) NOT NULL,
    `hotel_id` bigint(20) DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=23061 DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>So, i have table 'photos.'
  Now i want ALTER this table and add column 'type'.</p>
  
  <pre><code>ALTER TABLE photos
  ADD COLUMN type varchar(50) default 'jpg'
  </code></pre>
  
  <p>But there is one problem:
  column 'photo' contains path - '/foo/bar.jpg' or '/foo/bar.png' and i want to update 'type' column according to 'photo' column content. So type must be 'jpg' if photo ends with 'jpg' or type must be 'png' if photo ends with 'png'.</p>
  
  <p>I have no idea how to write such script...</p>